在Main Bundle目录中写入。 是否允许?

我非常肯定,在主要的Bundle中写作是不可能在iOS中…例如像这样的操作:

NSString *path = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"]; .....something [xmlData writeToFile:path atomically:YES]; 

为什么苹果公司文档中的第一个例子使用这个确切的代码?

这个例子是针对OS X的,与iOS的权限不尽相同。

但是,如果能够在Mac App Store应用程序包中更长时间地完成此操作(如果可以的话),我会感到惊讶。

这可能是值得提交有关文档的错误。

这不是一个主要的捆绑链接。 这是资源文件夹的path,并在该文件夹中的plist。

因此函数名称pathForResource...

当您编译应用程序时,主包中的所有内容都以encryption方式签名。 资源文件夹不是。 你可以自由地写信给你。

为@ jrturton

 // we need to get the plist data... NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Symptoms" ofType:@"plist"]; NSMutableArray *dataArray = [[NSMutableArray alloc] initWithContentsOfFile:plistPath]; // add a new entry NSDictionary *addQuestion = [[NSDictionary alloc] initWithObjectsAndKeys:@"Blank.png",@"Icon", [NSString stringWithFormat:@"%i",r],@"ID", [titleTextField text],@"Title", [questionTextField text],@"Text", qnType,@"Type", @"1",@"Custom", [NSArray arrayWithObjects:@"Yes",@"No",nil],@"Values", [unitsTextField text],@"Units", nil]; [dataArray addObject:addQuestion]; [addQuestion release]; // rewrite the plist [dataArray writeToFile:plistPath atomically:YES];