Add firstObject to NSArray and pals
Originator: | tony | ||
Number: | rdar://13650523 | Date Originated: | 15-Apr-2013 03:28 PM |
Status: | Duplicate/3058939 | Resolved: | April 20 2013, 3:51 AM |
Product: | iOS SDK | Product Version: | 6.1.3 |
Classification: | Enhancement | Reproducible: | Not Applicable |
Summary: Presently, there is no way to safely and quickly retrieve the first object in an array/collection. `objectAtIndex:` throws an exception if you request an out of bounds object, whereas `lastObject` safely does what it says on the box. Given how common it is to request the first object in an array, I'd love to see a simple addition to these guys: -(id)firstObject { if ([self count] > 0) { return [self objectAtIndex:0]; } return nil; } Any chance of that happening? I'll file the same against the OS X SDK.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Here's the OS X version:
http://www.openradar.me/13650524