objects conforming to nscoding will not writetofile

99封情书 提交于 2019-11-29 15:23:59

writeToFile:atomically: writes property list files, not serialised archives. Property list types can't be extended by implementing NSCoding, and as your objects aren't one of the types supported by property lists, then they can't be written to a property list.

To archive your objects, you'll need to use an NSAchiver, for example:

[NSKeyedArchiver archiveRootObject:questions 
                 toFile:@"some/path/questions.archive"]
visakh7

Taken from here NSMutableArray writeToFile:atomically always returns NO on device but works fine on simulator

I don't think you can not write into the application's bundle so you can not write to a plist in the Resources directory. One good way is to copy the plist from the Resource directory into the Documents directory on first launch and access it from there in the future..

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