Posted By

gerhardsletten on 10/18/09


Tagged


Versions (?)

Fast enumeration


 / Published in: Objective C
 

  1. NSArray *array = [NSArray arrayWithObjects:
  2. @"One", @"Two", @"Three", @"Four", nil];
  3.  
  4. for (NSString *element in array) {
  5. NSLog(@"element: %@", element);
  6. }
  7.  
  8. NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
  9. @"quattuor", @"four", @"quinque", @"five", @"sex", @"six", nil];
  10.  
  11. NSString *key;
  12. for (key in dictionary) {
  13. NSLog(@"English: %@, Latin: %@", key, [dictionary valueForKey:key]);
  14. }

Report this snippet  

You need to login to post a comment.