I have a basic iOS app that interfaces with a Rails app. The idea here is to load all channel objects from my RESTful /channels.json route set up in Rails.
I want to load all of the Channel objects into an NSDictionary in Xcode so that they can easily be identified using the Channel object’s ID generated by ActiveRecord — something along the lines of [dictionary objectForKey:@"1"]
I’ve had no trouble loading all the Channel objects into an NSArray, but getting them to load into an NSDictionary is proving tough. I’ve implemented RestKit’s didLoadObjectDictionary delegate method, and have set up my JSON response as follows: https://gist.github.com/2504664
I believe I have my mapping set up incorrectly. The mapping for the Channel objects is set up as follows: https://gist.github.com/2504667
When the didLoadObjectDictionary method is called, the objects NSDictionary contains 0 key/value pairs.
How do I go about loading all Channel objects into an NSDictionary so that I can easily refer to them using objectForKey as explained above?
You can still fetch things out of the nsarray using a predicate:
It returns another NSArray (which should have one object).
Alternatively you could use restkit’s coredata mappings then simply fetch the object by ID out of core data.