NSDictionary with NSNumber to NSString mapping is non-property-list object

佐手、 提交于 2019-11-29 12:10:18

The only way you can save a dictionary to NSUserDefaults (or write the dictionary to a file as a plist), all keys MUST be NSString objects and all values must be valid plist objects.

In other words, you can't have keys that are NSNumber objects. Convert them to NSString if you need to write the dictionary to NSUserDefaults.

For details on this, see the Property List Programming Guide. Specifically the section titled What is a Property List?. There is a table showing the XML tags used. Under that table you will see this excerpt:

And although NSDictionary and CFDictionary objects allow their keys to be objects of any type, if the keys are not string objects, the collections are not property-list objects.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!