嗨,我正在尝试将 NSDictionary 写入文档文件夹中的 plist,但无法写入,我正在使用 writeToFile:atomically: 方法,该方法返回 False。完整代码为
-(void)writeData:(NSDictionary *)dicResponseData
{
// get paths from root directory
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"Contractors.plist"];
[dicResponseData writeToFile:plistPath atomically: TRUE];
}
该词典包含 25 个子词典。
最佳答案
字典中的所有对象都必须是属性列表对象。
This method recursively validates that all the contained objects are property list objects (instances of NSData, NSDate, NSNumber, NSString, NSArray, or NSDictionary) before writing out the file, and returns NO if all the objects are not property list objects, since the resultant file would not be a valid property list.
关于ios - 将 NSDictionary 写入 plist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10835135/