This shows you the differences between two versions of the page.
| — |
objective-c:foundation.framework:nsdictionary.h:allkeys [2024/02/16 01:12] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== allKeys ===== | ||
| + | <code objc> | ||
| + | |||
| + | - (NSArray *)allKeys | ||
| + | |||
| + | </code> | ||
| + | |||
| + | Returns a new array containing the dictionary’s keys, or an empty array if the dictionary has no entries. | ||
| + | |||
| + | **Return Value** | ||
| + | - NSArray | ||
| + | |||
| + | ===== ObjC Sourcecode Example ===== | ||
| + | |||
| + | <code objc> | ||
| + | |||
| + | // ** Init dictionary with entries | ||
| + | NSDictionary *myDictionary = [[NSDictionary alloc]initWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil]; | ||
| + | |||
| + | NSArray *keysArray = [myDictionary allKeys]; | ||
| + | |||
| + | // ** Output dictionary keys | ||
| + | NSLog(@"myDictionary all keys: %@", keysArray); | ||
| + | |||
| + | </code> | ||
| + | |||
| + | |||
| + | ==== Output for this example code ==== | ||
| + | <code> | ||
| + | |||
| + | 2014-06-08 01:47:29.180 NSDictionary[3462:70b] myDictionary all keys: ( | ||
| + | key2, | ||
| + | key1 | ||
| + | ) | ||
| + | |||
| + | </code> | ||