lmr001
6/6/2013 - 5:41 AM

Enumerate an array : block based and standard

Enumerate an array : block based and standard

// block-based solution
[window.subviews enumerateObjectsWithOptions:NSEnumerationReverse 
                                  usingBlock:^(id view, NSUInteger idx, BOOL *stop) 
    {
        if ([view isKindOfClass:[UIImageView class]]){
            [view removeFromSuperview];
            *stop=YES;
    }
}];

// non-block solution:
for (UIView *view in [window.subview reverseObjectEnumerator])
{
    if ([view isKindOfClass:[UIImageView class]]){
            [view removeFromSuperview];
            break;
    }
}