2012-09-23 50 views
0

任何人都可以告訴我爲什麼我在調用loadObjectsAtResourcePath時完全沒有任何行爲?在日誌中沒有任何東西,我根本沒有在我的類上定義的代表被調用。RestKit 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); 
} 
+0

是定義爲委託的父對象,因此它可以響應方法調用? – clopez

回答

0

在你的@interface中你使用的是<RKObjectLoaderDelegate>?除非實現,否則ObjectLoader不會獲得消息。