1

好的,所以在升级到 0.20.xi 之前,我的课程是这样路由的

[[RKObjectManager sharedManager].router routeClass:[Player class] toResourcePath:@"/player" forMethod:RKRequestMethodGET];
[[RKObjectManager sharedManager].router routeClass:[Player class] toResourcePath:@"/player" forMethod:RKRequestMethodPOST];
[[RKObjectManager sharedManager].router routeClass:[Player class] toResourcePath:@"/player" forMethod:RKRequestMethodPUT];
[[RKObjectManager sharedManager].router routeClass:[Player class] toResourcePath:@"/players" forMethod:RKRequestMethodDELETE];

[[RKObjectManager sharedManager].router routeClass:[WTFGameInfo class] toResourcePath:@"/game"forMethod:RKRequestMethodGET];
[[RKObjectManager sharedManager].router routeClass:[WTFGameInfo class] toResourcePath:@"/game" forMethod:RKRequestMethodPOST];
[[RKObjectManager sharedManager].router routeClass:[WTFGameInfo class] toResourcePath:@"/game/:gameID" forMethod:RKRequestMethodPUT];
[[RKObjectManager sharedManager].router routeClass:[WTFGameInfo class] toResourcePath:@"/games" forMethod:RKRequestMethodDELETE];

但是,使用 PathPatterns 已经发生了如此细微的变化,我想知道我是否可以将资源路径中的字符串完全一样,或者我必须将其更改为看起来像这样。

[[RKObjectManager sharedManager].router.routeSet addRoute:[RKRoute routeWithClass:[Player class] pathPattern:@"/player/:_id" method:RKRequestMethodGET]];//posibly do it for _fbID;
[[RKObjectManager sharedManager].router.routeSet addRoute:[RKRoute routeWithClass:[Player class] pathPattern:@"/player/:_id" method:RKRequestMethodPOST]];//posibly do it for _fbID;
[[RKObjectManager sharedManager].router.routeSet addRoute:[RKRoute routeWithClass:[Player class] pathPattern:@"/player/:_id" method:RKRequestMethodPUT]];//posibly do it for _fbID;

[[RKObjectManager sharedManager].router.routeSet addRoute:[RKRoute routeWithClass:[WTFGameInfo class] pathPattern:@"/game/:_id" method:RKRequestMethodGET]];//posibly do it for @"/game/:gameID";
[[RKObjectManager sharedManager].router.routeSet addRoute:[RKRoute routeWithClass:[WTFGameInfo class] pathPattern:@"/game/:_id" method:RKRequestMethodPOST]];//posibly do it for @"/game/:gameID";
[[RKObjectManager sharedManager].router.routeSet addRoute:[RKRoute routeWithClass:[WTFGameInfo class] pathPattern:@"/game/:_id" method:RKRequestMethodPUT]];//posibly do it for @"/game/:gameID";

谁能为我澄清一下?谢谢...

4

1 回答 1

1

这可以 :

[[RKObjectManager sharedManager].router.routeSet addRoute:[RKRoute routeWithClass:[Player class] pathPattern:@"player/:playerId" method:RKRequestMethodGET]];

为了让你的播放器,类似这样的东西:

Player *player = [Player new];
player.playerID = 2;
[[RKObjectManager sharedManager] getObject:player path:nil parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *result) {
    // Request 
} failure:nil];
于 2012-12-17T18:37:06.773 回答