PDA

View Full Version : Array of NSDictionaries




BollywooD
Oct 2, 2009, 05:49 PM
so I have an NSArray of NSDictionaries, and I would like to return an NSArray of keys from these dictionaries.


where do I start?



lee1210
Oct 2, 2009, 05:55 PM
Do all of the dictionaries have the same keys? If so, just get the first element of the NSArray, and get the keys of the NSDictionary using allKeys. If not, for each array element get the keys and append them to an NSMutableArray with addObjectsFromArray.

-Lee

HiRez
Oct 2, 2009, 05:55 PM
NSDictionary has a method allKeys: and then you can combine the arrays using NSMutableArray's addObjectsFromArray:

BollywooD
Oct 2, 2009, 05:56 PM
All the dictionaries do have the same keys