Add firstObject: method existing since 10.6

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38595 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rmottola 2015-06-01 17:43:37 +00:00
parent d95d88c102
commit 36aa478b39
3 changed files with 22 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/** NSArray - Array object to hold other objects.
Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
Copyright (C) 1995-2015 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
From skeleton by: Adam Fedor <fedor@boulder.colorado.edu>
@ -978,6 +978,17 @@ static SEL rlSel;
return [self objectAtIndex: count-1];
}
/**
* Returns the first object in the receiver, or nil if the receiver is empty.
*/
- (id) firstObject
{
NSUInteger count = [self count];
if (count == 0)
return nil;
return [self objectAtIndex: 0];
}
/**
* Makes each object in the array perform aSelector.<br />
* This is done sequentially from the first to the last object.