Skip to content

Instantly share code, notes, and snippets.

@jackyshan
Created October 21, 2016 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackyshan/4678965cf06335d0a139f0cc497ba37e to your computer and use it in GitHub Desktop.
Save jackyshan/4678965cf06335d0a139f0cc497ba37e to your computer and use it in GitHub Desktop.
runtime轻松实现数组越界防止崩溃
- (id)jkobjectAtIndex:(NSUInteger)index {
if (index >= self.count) {
YTLog(@"数组越界了------%@", [self class]);
return nil;
}
return [self jkobjectAtIndex:index];
}
- (void)jkinsertObject:(id)anObject atIndex:(NSUInteger)index {
if (!anObject) {
YTLog(@"数组内插入了一个nil对象--------%@", [self class]);
return;
}
return [self jkinsertObject:anObject atIndex:index];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment