Skip to content

Instantly share code, notes, and snippets.

@DavidYKay
Created January 9, 2012 23:29
Show Gist options
  • Save DavidYKay/1585629 to your computer and use it in GitHub Desktop.
Save DavidYKay/1585629 to your computer and use it in GitHub Desktop.
RestKit Persistence Snippet
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {
[[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"LastUpdatedAt"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"Loaded statuses: %@", objects);
[self loadObjectsFromDataStore];
[_tableView reloadData];
}
- (void)loadObjectsFromDataStore {
[_statuses release];
NSFetchRequest* request = [RKTStatus fetchRequest];
NSSortDescriptor* descriptor = [NSSortDescriptor sortDescriptorWithKey:@"createdAt" ascending:NO];
[request setSortDescriptors:[NSArray arrayWithObject:descriptor]];
_statuses = [[RKTStatus objectsWithFetchRequest:request] retain];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment