How to get all the keys from the dictionary?

How can I get all the keys (only) from an NSDictionary? I do not need them in any particular order.

+1
ios objective-c key nsdictionary
source share
2 answers

Use the allKeys method on an NSDictionary .

In docs :

allKeys : returns a new array containing dictionary keys.

 - (NSArray *)allKeys 

Return value

A new array containing dictionary keys, or an empty array if the dictionary has no entries.

+17
source share

I advise you to study the Documentation. ;-) Look here:

- (NSArray *) allKeys;

From the doc:

Returns a new array containing dictionary keys.

  • (NSArray *) allKeys

Return value A new array containing dictionaries or an empty array if the dictionary has no entries.

Discussion The order of elements in an array is undefined.

0
source share

All Articles