开发者

Serializing/Storing a UIView and its subviews

I'm a relatively new iOS developer, with most of my previous experience coming from .NET. My application is a canvas lik开发者_开发技巧e system in that there is a parent UIView that contains all the objects the user is placing/resizing/etc as subviews. I want to be able to save these positions/configurations to named files.

In .NET, I would have simply subclassed UIView, given it a "title" property, then serialized this to file, and then deserialized them to load them back, but in Cocoa I'm quite lost.

Originally I thought I could do this using NSCoding, but this doesn't seem to be a good solution for multiple file saving.

So I looked at Core Data, but I'm not sure how I can create Core Data objects of existing Cocoa UIKit classes like UIView.

I've spent a while googling and can't find any information about this kind of predicament. What should I use, and what is the best way to go about it?


You probably could do it with NSKeyedArchiver, since UIView implements NSCoding. A more MVC-oriented design, however, would be to have the user manipulate a data model by moving the views around. To save, you'd archive the model rather than the views themselves.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜