I use RestKit in my iPhone application to download a list of countries. The problem is that the elementToPropertyMappings method uses a dictionary to map each object. In my case, I have an array of strings that I would like to map to the name property in my Country class.
Does anyone know how to do this?
elementToPropertyMappings
Should return a dictionary containing a mapping from the names of JSON elements to resource access devices
- (NSDictionary *) elementToPropertyMappings Announced in RKObjectMappable.h
My JSON data
["Argentina","Australia","Austria","Belgium","Bolivia","Brazil","Bulgaria","Canada","Cayman Islands","China","Costa Rica","Croatia","Czech Republic","Denmark","Ecuador","Ethiopia","FYRO Macedonia","Finland","France","French Polynesia","Germany","Guam","Hong Kong SAR","Indonesia","Ireland","Israel","Italy","Japan","Latvia","Lithuania","Luxembourg","Malaysia","Malta","Mexico","Morocco","Netherlands","New Zealand","Nicaragua","Norway","Papua New Guinea","Peru","Poland","Portugal","Puerto Rico","Qatar","Romania","Russia","Singapore","Slovakia","Slovenia","South Africa","South Korea","Spain","Sweden","Switzerland","Taiwan","United Arab Emirates","United Kingdom","United States","Venezuela","Vietnam"]
UPDATE:
I figured out how to use RKClient to query so that the mapping function is skipped. Now I need to figure out which class to use for parsing JSON. The yajl-objc parser looks great, but I don't want to include another parser if this can be done using lib from RestKit.
-(void)loadLocations { NSLog(@"loadLocations"); RKObjectManager *objectManager = [RKObjectManager sharedManager]; [[RKClient sharedClient] get:@"/locations/countries.json" delegate:self]; } - (void)request:(RKRequest*)request didLoadResponse:(RKResponse*)response { NSLog(@"Loaded payload: %@", [response bodyAsString]);