谁能告诉我为什么当我调用 loadObjectsAtResourcePath 时我的行为完全没有?日志中没有任何内容,我在课堂上定义的任何代表都没有被调用。
RKObjectMapping* roundMapping = [RKObjectMapping mappingForClass:[Round class]];
[roundMapping mapKeyPath:@"Id" toAttribute:@"id"];
[roundMapping mapKeyPath:@"Name" toAttribute:@"name"];
[roundMapping mapKeyPath:@"Description" toAttribute:@"description"];
[roundMapping mapKeyPath:@"NumberOfPlayers" toAttribute:@"numberOfPlayers"];
[roundMapping mapKeyPath:@"PlayerLimit" toAttribute:@"playerLimit"];
[roundMapping mapKeyPath:@"Url" toAttribute:@"url"];
[[RKObjectManager sharedManager].mappingProvider addObjectMapping:roundMapping];
[RKObjectManager sharedManager].client.baseURL = [RKURL URLWithString:@"http://69.999.150.71:1023/service/"];
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/lobby2" delegate:self];
//[RKClient clientWithBaseURLString:@"http://69.999.150.71:1023/service/"];
//[[RKClient sharedClient] get:@"/lobby?format=JSON" delegate:self];
}
return self;
}
- (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);
}
- (void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response
{
NSLog(@"Loaded payload: %@", [response bodyAsString]);
}
- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)objects
{
NSLog(@"Loaded: %@", objects);
}