Skip to content

Instantly share code, notes, and snippets.

@alexrozanski
Created March 6, 2010 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexrozanski/323983 to your computer and use it in GitHub Desktop.
Save alexrozanski/323983 to your computer and use it in GitHub Desktop.
@interface NSArray (PXArrayAdditions)
- (id)initWithObject:(id)object;
- (id)firstObject;
@end
@implementation NSArray (PXArrayAdditions)
- (id)initWithObject:(id)object
{
return [self initWithObjects:object,nil];
}
//Follows -lastObject in that returns nil if no objects present
- (id)firstObject
{
if([self count]>0) {
return [self objectAtIndex:0];
}
else {
return nil;
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment