Skip to content

Instantly share code, notes, and snippets.

@mickeyl
Created March 11, 2016 10:06
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 mickeyl/d266e567da2e3af2ac0b to your computer and use it in GitHub Desktop.
Save mickeyl/d266e567da2e3af2ac0b to your computer and use it in GitHub Desktop.
A taste of Python in Objective-C
@implementation NSString (IndexedSubscripting)
-(NSString*)objectAtIndexedSubscript:(NSInteger)index
{
NSRange range = NSMakeRange( index < 0 ? self.length + index: index, 1 );
return [self substringWithRange:range];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment