Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stopping a block enumeration fo a NSDictionary

How do I stop an enumeration here if I am doing the following? I think the docs said that to set stop = TRUE. but when I do that inside the block it says that it isn't unassignable.

 [self.visibleViewControllers_ enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {

            if (CGRectIntersectsRect(visibleRect, viewRect)) {
               //break here
            }
        }];
like image 748
xonegirlz Avatar asked Jul 17 '12 04:07

xonegirlz


2 Answers

Set *stop to YES

[self.visibleViewControllers_ enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {

            if (CGRectIntersectsRect(visibleRect, viewRect)) {
               *stop =YES;
               return;
            }
        }];
like image 110
Parag Bafna Avatar answered Oct 03 '22 06:10

Parag Bafna


For SWIFT 2:

Dict.enumerateKeysAndObjectsUsingBlock { (key, value, stop) -> Void in

            if(//Something){
                 //Do Something
            }
            else {
                //To Stop
                stop.memory = true
            }
        }
like image 29
Maddiee Avatar answered Oct 03 '22 04:10

Maddiee