Leveraging object subscripting, Rounak Jain wrote a category on NSArray that provides access to a range of values in a manner similar to Ruby (.. syntax).
1 2 |
NSArray *array = [NSArray arrayWithObjects:@"porter",@"ipa",@"stout",@"pale ale",@"pilsner", nil]; NSLog(@"%@",array[@"2..4"]); |
Range checking would be a nice addition, as well as support for … syntax, where the starting value is included but not the ending value.