Skip to content

Instantly share code, notes, and snippets.

@codeswimmer
Created January 10, 2012 13:25
Show Gist options
  • Select an option

  • Save codeswimmer/1589080 to your computer and use it in GitHub Desktop.

Select an option

Save codeswimmer/1589080 to your computer and use it in GitHub Desktop.
iOS: Log all keys and values from a NSDictionary
-(void)logAllKeys:(NSDictionary *)userInfo
{
NSArray *allKeys = [userInfo allKeys];
for (NSString *key in allKeys) {
id value = [userInfo valueForKey:key];
NSString *valueString = @"";
if ([value isKindOfClass:[NSString class]])
valueString = (NSString *)value;
else if ([value isKindOfClass:[NSNumber class]])
valueString = [(NSNumber *)value stringValue];
NSLog(@" %@: %@", key, valueString);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment