Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 在iOS5模拟器上更新现有plist_File_Ios5_Plist_Simulator - Fatal编程技术网

File 在iOS5模拟器上更新现有plist

File 在iOS5模拟器上更新现有plist,file,ios5,plist,simulator,File,Ios5,Plist,Simulator,我试图在iOS5模拟器上更新现有的plist,但失败惨重 它查找plist并检索现有信息并更新数组,但不写入文件 有人会有什么想法吗 NSString*path=[[NSBundle mainBundle]pathForResource:@“content\u iPhone”类型:@“plist”]; NSMutableArray*plist=[[NSMutableArray arrayWithContentsOfFile:path]mutableCopy]; //出于测试目的,从数组中获取一个

我试图在iOS5模拟器上更新现有的
plist
,但失败惨重

它查找plist并检索现有信息并更新数组,但不写入文件

有人会有什么想法吗

NSString*path=[[NSBundle mainBundle]pathForResource:@“content\u iPhone”类型:@“plist”];
NSMutableArray*plist=[[NSMutableArray arrayWithContentsOfFile:path]mutableCopy];
//出于测试目的,从数组中获取一个对象并将该对象添加到数组中
newObject=[plist objectAtIndex:1];
[plist addObject:newObject];
[plist writeToFile:原子路径:YES];

您无法写入应用程序包中的文件,只能从中读取

您可以将文件写入用户的Documents目录:查看

NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)
这将返回一个数组,其中的第一个对象将是应用程序的用户文档目录的路径。您可以在应用程序第一次运行时将文件复制到该位置,并在将来在该位置进行更新