views:

116

answers:

2

I'm creating a "utility" type application with a main and flipside view, and an underlying "model" which the flipside view edits, and the main view "consumes".

Following on from this question: http://stackoverflow.com/questions/263118/iphone-os-utility-app-flipside-view-and-main-view-communication

My question is: where should the model be stored, both physically and logically? and what format should the model be? - an NSObject or a raw C-Struct?

The model contains 7-8 items of data that are simply bools and NSIntegers - nothing fancy. Any sample code or tutorials would be great, I'd rather not have to trawl through videos.

+3  A: 

I store my model as an archived object in NSUserDefault. I suggest use NSObject-derived model as it's easier to save/load it from development point of view.

gonzo
*Definitely* use either NSUserDefault or an archived NSArray/NSDictionary for this - the Cocoa keyed archiver methods make these approaches pretty trivial to implement.
Tim
Thanks - so who owns the model? The app delegate? Or is it a global? :-)
Justicle
Oh sorry, NSUserDefault is already global. Thanks for the tip +1.
Justicle
+1  A: 

Generically, the model should be owned by the application delegate. NSUserDefaults is just a variation of this. If you create an app in xcode using core data, the template automatically attaches it to the application delegate.

It needs to be in a high level/global location because multiple controllers in many different circumstances may need to accesses it.

TechZen