Breaking News
Home / iOS / ObjectiveC / How to print NSDictionary in Objective C?

How to print NSDictionary in Objective C?

Solution

NSDictionary *dict = nil;
dict = [NSDictionary dictionaryWithObject: @"1" forKey: @"one"];

// method 1

for(NSString *key in dict)

  NSLog(@”key : %@”,key); 

  NSLog(@”value : %@”,[[dic valueForKey:key] string]);

}

// method 2
NSEnumerator *enu = [dict keyEnumerator];

for(NSString *key in enu)

{     

   NSLog(@”key : %@”,key);     

   NSLog(@”value : %@”,[[dic valueForKey:key] string]);
 }

Check Also

Singleton Example in Objective C?

Solution static MyManager *sharedManager = nil; +(MyManager*) sharedManager {         if (sharedManager == nil)         …

Advertisment ad adsense adlogger