So is there a countForKey or something similar to that for NSDictionary? I do know that there is a count method but is there something like countForKey or do I have to make a NSDictionary category for it?
Even though [dictionary count] seems like the easiest approach, you could get the array of keys from the dictionary and then retrieve the array count, so:
NSUInteger keyCount = [dictionary count];
would return the same as:
NSUInteger keyCount = [[dictionary allKeys] count];
EDIT: With the additional information you provided in the comment, if you want to find out how many 'keys' (although your true requirement still isn't that clear):
NSUInteger keyCountForObject = [[dictionary allKeysForObject:object] count];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With