I have an NSMutableArray of UIViews that I put in UIScrollView which is responsible for putting them in order. Right now I have this code for changing two UIViews positions with each other:
UIView *viewToBeChanged = [views objectAtIndex:self.page];
UIView *previousView = [views objectAtIndex:previousPage];
[views removeObjectAtIndex:self.page];
[views removeObjectAtIndex:previousPage];
[views insertObject:viewToBeChanged atIndex:previousPage];
[views insertObject:previousView atIndex:self.page];
Is there a better way to change the position of an object in NSMutableArray with another one? Thanks!
replaceObjectAtIndex: withObject:orexchangeObjectAtIndex:withObjectAtIndex:orreplaceObjectAtIndex: withObjectAtIndex:as per your requirement.