-
-
Save BetrayalPromise/7202f1d158ce3ad43777a930cee47584 to your computer and use it in GitHub Desktop.
Gets the first object in an array or returns nil for empty array.
This file contains hidden or 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
| // | |
| // NSArray+FirstObject.h | |
| // | |
| #import <Foundation/Foundation.h> | |
| @interface NSArray (FirstObject) | |
| - (id)firstObject; | |
| @end |
This file contains hidden or 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
| // | |
| // NSArray+FirstObject.m | |
| // | |
| #import "NSArray+FirstObject.h" | |
| @implementation NSArray (FirstObject) | |
| - (id)firstObject | |
| { | |
| return self.count > 0 ? self[ 0 ] : nil; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment