我有一个plist文件,我想解析它并将其内容复制到NSArray中,并且我正在使用的代码是。解析.plist文件中的问题
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *fooPath = [documentsPath stringByAppendingPathComponent:@"myfirstplist.plist"];
NSLog(fooPath);
self.myArray = [[NSArray arrayWithContentsOfFile:fooPath] retain];
NSLog(@"%@",myArray);
现在问题很奇怪,有时候当我打印myArray内容时,它会打印文件数据,有时候它不会。
即使我使用URL作为路径,我也面临同样的问题。
self.myArray = [[NSArray arrayWithContentsOfURL:URlPath] retain];
会是什么原因?
在此先感谢。
不打印数组内容时,会发生什么?是否有错误,或日志是否显示(空)? – 2008-12-01 06:52:19