[[self.delegate ifResponds] aSelector];
can be used instead of:
if ([self.delegate respondsToSelector:@selector(aSelector)]) {
[self.delegate performSelector:@selector(aSelector) withObject:self];
}
- (NSArray *)customerNames {
return [self.allCustomers collect] name];
}
can be used instead of:
- (NSArray *)customerNames {
NSMutableArray *allNames = [NSMutableArray alloc] init];
for (Customer *customer in [self allCustomers]) {
[allNames addObject:customer.name];
}
return [allNames copy];
}
where Customer
:
@interface Customer: NSObject
@property (nonatomic, copy, nonnull) NSString *name;
@end
More informations:
-
Marcel Weiher and Stéphane Ducasse. 2005. Higher order messaging. In Proceedings of the 2005 symposium on Dynamic languages (DLS '05). ACM, New York, NY, USA, 23-34.