Key-Value Coding

别来无恙 提交于 2019-12-05 09:12:29

You can still use key value coding methods on your custom class, as long as you name your variables appropriately there's no difference there. With that being said though, when I'm working with XML I usually end up testing each node name or creating a key lookup table, since the names in the data source I'm working with aren't key value coding compliant. If you have control over the data source though, you could just continue to use setValue:forKey:.

I'd recommend reading this guide about key value coding if you haven't already. It's fundamental to many great tools in Cocoa.

Look into NSCoding. You can use the NSCoding protocol to save your object, properties and all, as data.

Once your object is NSCoding compliant, you can just archive the whole array of objects using NSKeyedArchiver.

Please note that if you have a large number of objects, this can dramatically affect the app's performance on the iPhone during load and save.

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