0

嗨,我正在尝试将 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 个子词典。

4

1 回答 1

1

字典中的所有对象都必须是属性列表对象。

此方法在写出文件之前递归地验证所有包含的对象是属性列表对象(NSData、NSDate、NSNumber、NSString、NSArray 或 NSDictionary 的实例),如果所有对象都不是属性列表对象,则返回 NO,因为结果文件不是有效的属性列表。

于 2012-05-31T21:39:55.860 回答