Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
//
// NSArray+IndexHelper.h
// C_POS
//
// Created by Tomohisa Takaoka on 6/14/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSArray (IndexHelper)
-(id) safeObjectAtIndex:(NSUInteger)index;
@end
//
// NSArray+IndexHelper.m
// C_POS
//
// Created by Tomohisa Takaoka on 6/14/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "NSArray+IndexHelper.h"
@implementation NSArray (IndexHelper)
-(id) safeObjectAtIndex:(NSUInteger)index {
if (index>=self.count) {
return nil;
}
return [self objectAtIndex:index];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment