views:

48

answers:

2

I have just been reading about the MVC design pattern for Cocoa-Touch applications and it suggested using a property list for the model. My question is if you needed to do some calculation on the data in the property list where would the code for that calculation go?

In the past I have used a singleton object for my model and then used that to access data and do any processing, I am just curious how others go about setting this up ...

Gary

A: 

You can use a Property list for storing basic (read fairly flat) data. If you want to read from the plist and then do a calc and write that back into a different field in the plist that should be no problem.

If instead by calculations your are implying you want a relational database, the following link provides a simple comparison of options to store the 'models' part of your cocoa app.

http://tapity.com/iphone-app-development/readwrite-data-on-the-iphone-property-lists-sqlite-or-core-data/

Cheers

Evolve

Evolve
+1  A: 

I don't think that a plist is a model, it's just a way to store your model data. It's one part of the model. You could use an SQLite database to store the data without changing the model of your program. You should be able to change the way your program stores its information without the controller parts having to change.

A plist is good for a small amount of data, up to around 50 items. It starts to get less manageable after this, and a database is a better option. If you want to do searching or ordering a database can make your life easier.

So suggesting a plist for the model (storage) is only correct in some situations. Thinking that the plist is the model is not the full picture.

I found the MVC descriptions in the Big Nerd Ranch iPhone book to be one of the best.

nevan
Thank you, I have that book so I will take a look for that chapter/description. Many thanks, much appreciated.
fuzzygoat