objective c - What is the correct way to setup a Model for IOS? -


i creating app , using parse.com data storage.

i use model different aspects of parse use. example, if store game data model handle doing finds/updates/entries game model held on parse.

so model handle these methods, instead of adding these view controllers.

what best/correct way set these up? have heard of singletons not sure if correct here.

at present, set these using subclass of nsobject. create methods class methods (no instance methods there no instance create). call class method usual.

[gamemodel classmethodname]; 

would correct? there better approach or issues approach?

at present, set these using subclass of nsobject. create methods class methods (no instance methods there no instance create). call class method usual.

this doesn't sound plan. job of model manage data application operates on. means model should have data store, means should instantiating model.

building support end infrastructure (parse, in case) idea. it's better put there put in view controllers. supporting code store game state, example, or player's history? should store in model object(s).

without getting whole singletons vs. singletons bad can of worms (you should google that), sounds you're using class methods same reason people use singletons: easy access. instantiating class , using instance methods instead of class methods mean have find way share model objects need it, , that's more work using globally accessible class methods. doing work make better application, though.

for example, restrict each view controller's access parts of model needs. game play view controller might see current game board, , high scores view controller see player's history. eliminates many possible bugs -- you'll never have wonder if game board view controller causing problem player history, because never sees part of model.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -