Is there a way to find how many keys are currently in an NSMutableDictionary?

Curious, is there a way to find the number of keys in an NSMutableDictionary? Is there also a way to access each key in turn and find its value, or do I need to access the data manually using predefined keys?

(those.).

myTown  = [cryo objectForKey: @"town"];
myZip   = [cryo objectForKey: @"HT6 4HT"];
myEmail = [cryo objectForKey: @"pink@grapefruit.xxx"];

Think I'm thinking of using a wildcard or something for the key?

Gary

+3
source share
2 answers
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
NSLog(@"%d", [[dict allKeys] count]);

[dict allKeys] gives you a list of all current keys.

+1
source

Source: https://habr.com/ru/post/1719113/


All Articles