Created
January 6, 2013 17:28
-
-
Save johnclayton/4468810 to your computer and use it in GitHub Desktop.
NSArray first element convenience
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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