iOS JSON – Should Specific Classes Be Created for JSON Objects or Use Container?

arrayclassiosjson

I'm using Foursquare to get a List of Restaurants nearby inside an iOS app. The Result is stored in an Array which consists of Dictionaries and regarding how deep the Data is, each Dictionary contains also an Array with Dictionaries and so on. The Result should be shown inside a UITableView. Should I create a Class that represents a Restaurant and then create an instance for every Restaurant which I put in an Array and use this as the Data Source for my UITableView or should I use the complete Array I got the first Time.
I think, using an Array with a dedicated Restaurant class would make the handling much easier but maybe there are reasons to not do it this way? Performance maybe?

Best Answer

I would go with specific classes - it will be much easier to write unit tests and maintain code even if you lose some performance. It is not a place where you should prefer performance over clarity.

Related Topic