mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 04:20:21 +08:00
Core Data example updates: Parse dates properly. Sort fetched statuses.
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
}
|
||||
|
||||
- (NSString*)description {
|
||||
return [NSString stringWithFormat:@"%@ (ID: %@)", self.text, self.statusID];
|
||||
return [NSString stringWithFormat:@"%@ (ID: %@ Date: %@)", self.text, self.statusID, self.createdAt];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -29,6 +29,12 @@
|
||||
// Add our element to object mappings
|
||||
[mapper registerClass:[RKTUser class] forElementNamed:@"user"];
|
||||
[mapper registerClass:[RKTStatus class] forElementNamed:@"status"];
|
||||
|
||||
// Update date format so that we can parse twitter dates properly
|
||||
// Wed Sep 29 15:31:08 +0000 2010
|
||||
NSMutableArray* dateFormats = [[[mapper dateFormats] mutableCopy] autorelease];
|
||||
[dateFormats addObject:@"E MMM d HH:mm:ss Z y"];
|
||||
[mapper setDateFormats:dateFormats];
|
||||
|
||||
// Create Window and View Controllers
|
||||
RKTwitterViewController* viewController = [[[RKTwitterViewController alloc] initWithNibName:nil bundle:nil] autorelease];
|
||||
|
||||
@@ -49,11 +49,10 @@
|
||||
|
||||
- (void)loadObjectsFromDataStore {
|
||||
[_statuses release];
|
||||
_statuses = [[RKTStatus allObjects] retain];
|
||||
NSFetchRequest* request = [RKTStatus request];
|
||||
NSSortDescriptor* descriptor = [NSSortDescriptor sortDescriptorWithKey:@"statusID" ascending:NO];
|
||||
NSSortDescriptor* descriptor = [NSSortDescriptor sortDescriptorWithKey:@"createdAt" ascending:NO];
|
||||
[request setSortDescriptors:[NSArray arrayWithObject:descriptor]];
|
||||
[[RKTStatus objectsWithRequest:request] retain];
|
||||
_statuses = [[RKTStatus objectsWithRequest:request] retain];
|
||||
}
|
||||
|
||||
- (void)reloadButtonWasPressed:(id)sender {
|
||||
|
||||
Reference in New Issue
Block a user