【发布时间】:2014-10-25 02:06:20
【问题描述】:
我有以下代码:
//Find device directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//Define file name
NSString * fileName = [file objectForKey: (id) kCFFTPResourceName];
//File path to file
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,fileName];
//Download Plist from server and write to 'filePath'
[[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://url.net/directory/%@",[file objectForKey: (id) kCFFTPResourceName]]]] writeToFile:filePath atomically:YES];
//Load Plist from directory
NSURL *url = [NSURL URLWithString:filePath];
//Load Data into Array
mapDetails = [[NSMutableArray alloc ] initWithContentsOfURL:url];
NSLog(@"Here is the Dict %@",mapDetails);
我的问题是,array 是否被返回为“nil”,我的问题是什么??
我尝试了各种组合,但仍然无法将PLIST 中的字符串转换为NSMutableArray。
【问题讨论】:
-
当代码不能按预期工作时,最好将长行分成多行。每行调用一个方法并将结果分配给一个变量。它使代码更易于阅读和调试。将包含 5 个方法调用的行拆分为 5 行单独的代码。
标签: ios objective-c plist nsdata nsurl