Last active
August 29, 2015 14:01
-
-
Save vikingosegundo/ee3d5aec32983a9ee0c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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