Reputation: 15133
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: 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.
Upvotes: 1
Views: 287
Reputation: 64428
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.
Upvotes: 1
Reputation: 1340
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.
Upvotes: 3