I’m trying to create an iphone app which grabs a JSON string, parses it and displays a list of items in at table view.
I’m also attempting to use an Model-View-Controller (MVC) architecture for my project.
My question is in 2 parts:
1) How do I structure my different files to conform to this standard (MVC) ?
2) (more general) I’ve been going through a lot of XML parsing examples, and they seem to implement standard methods such as ‘requestDidFinishLoad’, ‘setActiveProperty’, etc… How can I find out exactly what methods I need to implement to successfully send a request and parse a JSON string?
Apple has great documentation on MVC. See this link.
The basic idea is to separate your app into the part responsible for displaying the data (the view), the data itself (the model) and the interface between the two (the controller).
In your case, if you are just parsing and displaying JSON and don’t need to save or edit the information, you can cut out the model and do all the work in the controller. Just make a UITableViewController subclass that parses the JSON into an array and uses the array as the data source for the table view. If storing the data permanently is important to you than you want to look at something like plists or CoreData.