首先,我对objective-c和ios开发真的很陌生。
我有一个从 Internet 下载的 .plist,然后用于填充 UITableView。我可以在 AppDelegate 中的 ApplicationDidLaunch 方法中让它工作,如下所示。
NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *finalPath = [path stringByAppendingPathComponent:@"Data.plist"];
NSURL *theFileURL = [NSURL URLWithString:@"http://dl.dropbox.com/u/8068058/Data.plist"];
NSDictionary *replace = [[NSDictionary alloc] initWithContentsOfURL:theFileURL];
if (replace != nil){
[replace writeToFile:finalPath atomically:YES];
}
然后我将它设置为 DataPath
NSString *Path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *DataPath = [Path stringByAppendingPathComponent:@"Data.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
self.data = tempDict;
[tempDict release];
这一切都很好,然后我填充 TableView 并显示它。如果我向显示表格的 NavgationController 添加一个“刷新”按钮。当我按下它并运行相同的下载代码时
[self.tableView reloadData];
我什么都没有,有人知道如何解决这个问题吗?