While loading a custom UIView from a xib
Instead of this:
NSArray *bundle = [[NSBundle mainBundle] loadNibNamed:@”CategoryView” owner:self options:nil];
CategoryView *categoryView = (CategoryView *)[bundle objectAtIndex:0];
for (id object in bundle) {
if ([object isKindOfClass:[CategoryView class]])
categoryView = (CategoryView *)object;
}
Isn’t this nicer and shorter?
CategoryView *categoryView = (CategoryView *)[[[NSBundle mainBundle] loadNibNamed:@”CategoryView” owner:self options:nil] objectAtIndex:0];