mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-05-27 17:49:08 +08:00
Implementation of Object Mapping 2.0 design:
* Removed RestKit from inheritance hierarchy * Mappings are implemented as concrete classes * Mapper is much more flexible & powerful * Much more robust error handling * Serialization is reimplemented as an object mapping operation * Added ability to serialize to JSON natively * Reworked Core Data integration * Simplified the codebase substantially
This commit is contained in:
@@ -51,8 +51,11 @@
|
||||
}
|
||||
|
||||
- (void)loadData {
|
||||
RKObjectManager* objectManager = [RKObjectManager sharedManager];
|
||||
[[objectManager loadObjectsAtResourcePath:@"/status/user_timeline/restkit.json" objectClass:[RKTStatus class] delegate:self] retain];
|
||||
// Load the object model via RestKit
|
||||
RKObjectManager* objectManager = [RKObjectManager sharedManager];
|
||||
RKObjectMapping* statusMapping = [objectManager.mappingProvider objectMappingForKeyPath:@"status"];
|
||||
|
||||
[objectManager loadObjectsAtResourcePath:@"/status/user_timeline/RestKit" objectMapping:statusMapping delegate:self];
|
||||
}
|
||||
|
||||
- (void)reloadButtonWasPressed:(id)sender {
|
||||
@@ -71,7 +74,10 @@
|
||||
}
|
||||
|
||||
- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error {
|
||||
UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
|
||||
UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@"Error"
|
||||
message:[error localizedDescription]
|
||||
delegate:nil
|
||||
cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
|
||||
[alert show];
|
||||
NSLog(@"Hit error: %@", error);
|
||||
}
|
||||
@@ -108,7 +114,8 @@
|
||||
cell.textLabel.backgroundColor = [UIColor clearColor];
|
||||
cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"listbg.png"]];
|
||||
}
|
||||
cell.textLabel.text = [[_statuses objectAtIndex:indexPath.row] text];
|
||||
RKTStatus* status = [_statuses objectAtIndex:indexPath.row];
|
||||
cell.textLabel.text = status.text;
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user