0

谁能告诉我为什么当我调用 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);
}
4

1 回答 1

0

在您的@interface 中您使用的是<RKObjectLoaderDelegate>?除非实现,否则 ObjectLoader 不会收到消息。

于 2012-12-12T02:46:13.870 回答