Skip to content

Instantly share code, notes, and snippets.

@langford
Last active August 29, 2015 13:56
Show Gist options
  • Save langford/9008754 to your computer and use it in GitHub Desktop.
Save langford/9008754 to your computer and use it in GitHub Desktop.
Cause IBOutletCollectionss are useful, but painful and ill supported by IB. You will want this code.
- (NSArray*)sortArrayByY:(NSArray*)array{
return [array sortedArrayUsingComparator:^NSComparisonResult(id label1, id label2) {
if ([label1 frame].origin.y < [label2 frame].origin.y) return NSOrderedAscending;
else if ([label1 frame].origin.y > [label2 frame].origin.y) return NSOrderedDescending;
else return NSOrderedSame;
}];
}
- (void)clearTextInArray:(NSArray*)array{
for (UILabel* label in array){
label.userInteractionEnabled = NO;
label.textColor = [UIColor blackColor];
label.text = @"";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment