Author: rmottola
Date: Mon Jun 1 19:43:37 2015
New Revision: 38595
URL: http://svn.gna.org/viewcvs/gnustep?rev=38595&view=rev
Log:
Add firstObject: method existing since 10.6
Modified:
libs/base/trunk/ChangeLog
libs/base/trunk/Headers/Foundation/NSArray.h
libs/base/trunk/Source/NSArray.m
Modified: libs/base/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=38595&r1=38594&r2=38595&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog (original)
+++ libs/base/trunk/ChangeLog Mon Jun 1 19:43:37 2015
@@ -1,3 +1,9 @@
+2015-06-01 Riccardo Mottola <[email protected]>
+
+ * Headers/Foundation/NSArray.h
+ * Source/NSArray.m
+ Add firstObject: method existing since 10.6
+
2015-05-26 Richard Frith-Macdonald <[email protected]>
* Source/NSURLConnection.m: Fix leak of limit date
Modified: libs/base/trunk/Headers/Foundation/NSArray.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Headers/Foundation/NSArray.h?rev=38595&r1=38594&r2=38595&view=diff
==============================================================================
--- libs/base/trunk/Headers/Foundation/NSArray.h (original)
+++ libs/base/trunk/Headers/Foundation/NSArray.h Mon Jun 1 19:43:37 2015
@@ -1,5 +1,5 @@
/* Interface for NSArray for GNUStep
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1995-2015 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <[email protected]>
Created: 1995
@@ -105,6 +105,9 @@
- (id) initWithObjects: (const id[])objects
count: (NSUInteger)count;
- (id) lastObject;
+#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
+- (id) firstObject;
+#endif
/** <override-subclass />
* Returns the object at the specified index.
Modified: libs/base/trunk/Source/NSArray.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSArray.m?rev=38595&r1=38594&r2=38595&view=diff
==============================================================================
--- libs/base/trunk/Source/NSArray.m (original)
+++ libs/base/trunk/Source/NSArray.m Mon Jun 1 19:43:37 2015
@@ -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 <[email protected]>
From skeleton by: Adam Fedor <[email protected]>
@@ -976,6 +976,17 @@
if (count == 0)
return nil;
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];
}
/**
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs