开发者

MVC model design?

I have just been reading about the MVC design pattern for Cocoa-Touch applicati开发者_运维知识库ons 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


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.


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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜