Files
textmate/Frameworks/OakFoundation/src/NSArray Additions.mm
Ronald Wampler 8711228f9a Add safeObjectAtIndex to NSArray
This is defined in OakTabBarView as a static method, but it could be useful elsewhere.
2013-12-22 23:30:29 -05:00

14 lines
312 B
Plaintext

#import "NSArray Additions.h"
@implementation NSArray (Other)
- (id)firstObject
{
return [self count] ? [self objectAtIndex:0] : nil;
}
- (id)safeObjectAtIndex:(NSUInteger)anIndex
{
return (anIndex < [self count] && [self objectAtIndex:anIndex] != [NSNull null]) ? [self objectAtIndex:anIndex] : nil;
}
@end