开发者

The correct architecture: How to deliver an array of custom objects

Another architecture question.

I have a custom class calle Airfield. Let's say it has 2 ivars, name and tower frequency. It's in a class called Airfield with a .h and .m file.

Problem is, I want to read a whole bunch of airfields 开发者_运维技巧from an XML file and give them to a controller for a table view.

Should I create a new class called airfielddb which imports airfield for the single object definition and reads the XML creating an array of airfield objects?

Or do I declare an array as an ivar in Airfield.h?

I am really struggling with some of these OO Modeling type questions. Your help is very much appreciated.


Neither of this.
You should keep Airfield class as is- it's your model. There is no need in creating AirfieldDB class as well. You are loading data for tableview, and then you should implement the loading in your class implementing UITableViewDataSource which could be possibly your ViewController.

You can also check the nice example at: Apple's Table view Programming guide(listing 4-6)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜