Created
October 7, 2009 20:32
-
-
Save twoism/204419 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
// tmp is an incoming array of data from the server | |
// nearestExits is the existing store | |
for (int i=0; i<[tmp count]; i++) { | |
InterstateExit *incomingExit = [tmp objectAtIndex:i]; | |
InterstateExit *existingExit = [self.nearestExits objectAtIndex:i]; | |
if (![incomingExit.interstateExitID isEqualToNumber:existingExit.interstateExitID]) { | |
NSIndexPath *pathToRemove = [NSIndexPath indexPathForRow:i inSection:0]; | |
[self.nearestExits removeObjectAtIndex:i]; // remove the item from my datasource | |
[self.exitTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:pathToRemove] withRowAnimation:UITableViewRowAnimationFade]; | |
[self.nearestExits insertObject:incomingExit atIndex:i]; // add the new item to the datasource | |
[self.exitTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:pathToRemove] withRowAnimation:UITableViewRowAnimationFade]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment