I'm building an iPhone app that communicates with an external server via JSON. The JSON library I'm using parses the response string from the server into a dictionary. Currently I've got a method that I've written that just uses hardcoded strin开发者_如何学编程gs as keys for the dictionary in a constructor I've written called initWithDictionary:(NSDictionary *)dic
(e.g. self.name = [dic valueForKey:@"name"];
. Is there some smart idiomatic Objective-C way to do this?
Just call [someObject setValuesForKeysWithDictionary:dictFromJSON] to set an object's properties from a dictionary.
精彩评论