Instantly share code, notes, and snippets.

Embed
What would you like to do?
NSArray first element convenience
@interface NSArray (FSQFoundation)
- (id) firstObject; ///< @returns the first object if there is one, or nil.
@end
@implementation NSArray (FSQFoundation)
- (id) firstObject {
if (self.count < 1) {
return nil;
}
return [self objectAtIndex:0];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment