Just curious if there is a way to find the number of keys in a NSMutableDictionary? Also is there a way to access each key in turn and find its value, or do I need to access the data manually via the predefined keys?


myTown  = [cryo objectForKey: @"town"];
myZip   = [cryo objectForKey: @"HT6 4HT"];
myEmail = [cryo objectForKey: @"[email protected]"];

I guess I am thinking using a wildcard or something for the key?


NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
NSLog(@"%d", [[dict allKeys] count]);

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

+7  A: 

-[NSMutableDictionary count]

Barry Wark
thanks, should have known, I am starting to see a pattern with this language :)
Yes, the Cocoa frameworks are very well designed. You should expect that patterns you discover in one location will work in other parts of the framework. In the case of collection classes, the common API is consistent, even though there are no abstract base classes or interfaces for the collection API as in other languages/frameworks.
Barry Wark