我有一个 .net 网络服务,它以这种格式返回 Json 数据:
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:dataPlist options:NSJSONReadingMutableContainers error:&errorJson];
[
{
"MEMBERID": "xxx",
"PREFIXINFORMAL": "Mr.",
"FIRSTNAME": "xxx",
"MIDDLENAME": "xxxx",
"LASTNAME": "xxxx",
"SUFFIX": xxxx
}
]
我将此 NSDictionary 保存到 plist 的代码:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"boardMemberInfo.plist"];
NSDictionary *test = [NSDictionary dictionaryWithObject:@"test" forKey:@"test"];
for(NSDictionary *item in json) {
BOOL success = [item writeToFile:path atomically:YES];
if(success) {
NSLog(@"Success Saving New plist");
} else {
NSLog(@"Failure Saving New plist");
}
}
[item writeToFile...] 和 [json writeToFile...] 都不起作用。但是,简单的 [test writeToFile...] 有效。我错过了什么?
谢谢,