Reputation: 913
Is it possible to get all the keys from a specific NSDictionary
as a seperate NSArray
?
Upvotes: 90
Views: 73963
Reputation: 627
And if you want to get all keys and values, here's what you do:
for (NSString *key in dictionary) {
id value = dictionary[key];
NSLog(@"Value: %@ for key: %@", value, key);
}
Upvotes: 3
Reputation: 34185
Just use
NSArray*keys=[dict allKeys];
In general, if you wonder if a specific class has a specific method, look up Apple's own documentation. In this case, see NSDictionary class reference. Go through all the methods. You'll discover many useful methods that way.
Upvotes: 191