Graphics Programs Reference
In-Depth Information
feed will be represented by an NSDictionary . This NSDictionary will contain an
array of NSDictionary instances, and each dictionary will be an individual RSSItem .
While having the JSON data parsed into these common data structures is really conveni-
ent, it is sometimes useful to move this data into the appropriate model objects. In Nerd-
feed , the ListViewController knows how to present RSSChannel and
RSSItem s but not NSArray s and NSDictionary s. To keep things simple, we want to
transfer the data from the dictionaries and arrays into our own classes, RSSChannel and
RSSItem .
To do this, we will create a new protocol. This protocol will have one method,
readFromJSONDictionary: , that takes an NSDictionary as an argument. A
class that conforms to this protocol will implement readFromJSONDictionary: to
retrieve its instance variables from the dictionary. Both RSSChannel and RSSItem will
conform to this protocol. Create a new file from the Objective-C protocol template ( Fig-
ure 28.10 ) .
Figure 28.10 Creating an Objective-C protocol
 
Search WWH ::




Custom Search