Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. if (idx == [myArray indexOfObject:[myArray lastObject]]) {
  2. *stop = YES;
  3. }
  4.  
  5. for( id obj in arr ){
  6. if( [obj isContagious] ){
  7. break; // Stop enumerating
  8. }
  9.  
  10. if( ![obj isKindOfClass:[Perefrigia class]] ){
  11. continue; // Skip this object
  12. }
  13.  
  14. [obj immanetizeTheEschaton];
  15. }
  16.  
  17. [arr enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
  18. if( [obj isContagious] ){
  19. *stop = YES; // Stop enumerating
  20. return;
  21. }
  22.  
  23. if( ![obj isKindOfClass:[Perefrigia class]] ){
  24. return; // Skip this object
  25. }
  26.  
  27. [obj immanentizeTheEschaton];
  28. }];
  29.  
  30. - (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block {
  31. // N.B: This is probably not how this method is actually implemented!
  32. // It is just to demonstrate how the out parameter operates!
  33.  
  34. NSUInteger idx = 0;
  35. for( id obj in self ){
  36.  
  37. BOOL stop = NO;
  38.  
  39. block(obj, idx++, &stop);
  40.  
  41. if( stop ){
  42. break;
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement