Skip to content

Instantly share code, notes, and snippets.

@twoism
Created October 7, 2009 20:32
Show Gist options
  • Save twoism/204419 to your computer and use it in GitHub Desktop.
Save twoism/204419 to your computer and use it in GitHub Desktop.
// 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