Skip to content

Instantly share code, notes, and snippets.

@vikingosegundo
Last active August 29, 2015 14:01
Show Gist options
  • Save vikingosegundo/ee3d5aec32983a9ee0c6 to your computer and use it in GitHub Desktop.
Save vikingosegundo/ee3d5aec32983a9ee0c6 to your computer and use it in GitHub Desktop.
NSMutableArray *array = [@[@1,@2,@3,@4,@5, @6, @7, @8,@9, @10] mutableCopy];
for (int i =0 ; i< [array count]; ++i) {
if ([array[i] integerValue]> 3 && [array[i] integerValue]< 8) {
[array removeObjectAtIndex:i];
}
}
// we want to get an array containg [@1, @2, @3, @8, @9, @10]
// but we get [@1, @2, @3, @5, @7, @8, @9, @10]
// reversed: working but confusing for-loop signature
NSMutableArray *array = [@[@6, @1,@2,@3,@4,@5, @6, @7, @8,@9, @10] mutableCopy];
for (NSUInteger i = [array count] -1 ; i != NSUIntegerMax; --i) {
if ([array[i] integerValue]> 3 && [array[i] integerValue]< 8) {
[array removeObjectAtIndex:i];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment