Skip to content

Instantly share code, notes, and snippets.

@gblazex
Forked from tomohisa/NSArray+IndexHelper.h
Last active August 29, 2015 14:24
Show Gist options
  • Save gblazex/d7699dd7bc5bb9255c71 to your computer and use it in GitHub Desktop.
Save gblazex/d7699dd7bc5bb9255c71 to your computer and use it in GitHub Desktop.
//
// 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