Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Reverse an array in Objective C

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.11k
    Comment on it

    If you want to reverse an existing array in objc, you can do it this way.

        - (NSMutableArray*)reverseArray {
        if ([self.assetsArray count] == 0)
            return;
        NSUInteger i = 0;
        NSUInteger j = [self.assetsArray count] - 1;
        while (i < j) {
            [self.assetsArray exchangeObjectAtIndex:i
                      withObjectAtIndex:j];
            i++;
            j--;
        }
         return self.assetsArray;
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: