Created
April 18, 2011 22:31
-
-
Save alexfish/926390 to your computer and use it in GitHub Desktop.
Reverse an array in Objective-c
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
-(void)reverse { | |
int i = 0; | |
int j = [array count] - 1; | |
while (i < j) { | |
[array exchangeObjectAtIndex:i withObject:[array objectAtIndex:j]]; | |
i++ | |
j-- | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment