Skip to content

Instantly share code, notes, and snippets.

@johnclayton
Created January 6, 2013 17:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save johnclayton/4468810 to your computer and use it in GitHub Desktop.
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