这里说,字典中的key可以是遵守NSCopying协议的任何对象类型,但是 key-value coding中的key必须是一个string.
'- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile;'
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.
这里描述了写入文件的对象要求,也就是平时常用的 NSData, NSDate, NSNumber, NSString, NSArray, or NSDictionary这些类型,当然自定义类型不可以.
解决问题
当然最后的处理就是将NSNumber格式化为NSString,看下代码
NSString *dictKey = [NSString stringWithFormat:@"%@",dict[@"userId"]];
[userNameDict setObject:dict[@"userName"] forKey:dictKey];
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持ASPKU!
注:相关教程知识阅读请移步到IOS开发频道。










