Created
January 9, 2012 23:29
-
-
Save DavidYKay/1585629 to your computer and use it in GitHub Desktop.
RestKit Persistence Snippet
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
- (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