Skip to content

Commit

Permalink
Using a reverse enumerator, rather than a for loop for subview enumer…
Browse files Browse the repository at this point in the history
…ation.
  • Loading branch information
matej committed Nov 17, 2012
1 parent 0c579a9 commit b9ce4bf
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions MBProgressHUD.m
Expand Up @@ -125,12 +125,11 @@ + (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated {
} }


+ (MBProgressHUD *)HUDForView:(UIView *)view { + (MBProgressHUD *)HUDForView:(UIView *)view {
NSArray *subviews = view.subviews;
Class hudClass = [MBProgressHUD class]; Class hudClass = [MBProgressHUD class];
for (NSUInteger i = subviews.count - 1; i >= 0; i--) { NSEnumerator *subviewsEnum = [view.subviews reverseObjectEnumerator];
UIView *aView = [subviews objectAtIndex:i]; for (UIView *subview in subviewsEnum) {
if ([aView isKindOfClass:hudClass]) { if ([subview isKindOfClass:hudClass]) {
return (MBProgressHUD *)aView; return (MBProgressHUD *)subview;
} }
} }
return nil; return nil;
Expand Down

0 comments on commit b9ce4bf

Please sign in to comment.