mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 12:27:52 +08:00
Fix incorrect comments about retaining object loaders. Fixed deprecated references to globalManager/globalClient
This commit is contained in:
@@ -26,14 +26,20 @@
|
||||
// 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];
|
||||
UINavigationController* controller = [[UINavigationController alloc] initWithRootViewController:viewController];
|
||||
UIWindow* window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
|
||||
[window addSubview:controller.view];
|
||||
[window makeKeyAndVisible];
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,8 @@
|
||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
|
||||
// Load the object model via RestKit
|
||||
// Retain the object loader that is returned so that it is not dealloc'd after the request is sent.
|
||||
RKObjectManager* objectManager = [RKObjectManager globalManager];
|
||||
[[objectManager loadObjectsAtResourcePath:@"/status/user_timeline/twotoasters.json" objectClass:[RKTStatus class] delegate:self] retain];
|
||||
RKObjectManager* objectManager = [RKObjectManager sharedManager];
|
||||
[objectManager loadObjectsAtResourcePath:@"/status/user_timeline/twotoasters.json" objectClass:[RKTStatus class] delegate:self];
|
||||
}
|
||||
|
||||
|
||||
@@ -53,14 +52,12 @@
|
||||
[_statuses release];
|
||||
_statuses = [objects retain];
|
||||
[_tableView reloadData];
|
||||
[objectLoader release];
|
||||
}
|
||||
|
||||
- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error {
|
||||
UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
|
||||
[alert show];
|
||||
NSLog(@"Hit error: %@", error);
|
||||
[objectLoader release];
|
||||
}
|
||||
|
||||
#pragma mark UITableViewDelegate methods
|
||||
|
||||
@@ -57,8 +57,7 @@
|
||||
|
||||
- (void)reloadButtonWasPressed:(id)sender {
|
||||
// Load the object model via RestKit
|
||||
// Retain the object loader that is returned so that it is not dealloc'd after the request is sent.
|
||||
RKObjectManager* objectManager = [RKObjectManager globalManager];
|
||||
RKObjectManager* objectManager = [RKObjectManager sharedManager];
|
||||
[[objectManager loadObjectsAtResourcePath:@"/status/user_timeline/twotoasters.json" objectClass:[RKTStatus class] delegate:self] retain];
|
||||
}
|
||||
|
||||
@@ -70,14 +69,12 @@
|
||||
NSLog(@"Loaded statuses: %@", objects);
|
||||
[self loadObjectsFromDataStore];
|
||||
[_tableView reloadData];
|
||||
[objectLoader release];
|
||||
}
|
||||
|
||||
- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error {
|
||||
UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
|
||||
[alert show];
|
||||
NSLog(@"Hit error: %@", error);
|
||||
[objectLoader release];
|
||||
}
|
||||
|
||||
#pragma mark UITableViewDelegate methods
|
||||
|
||||
Reference in New Issue
Block a user