ios – RKResponseDescriptor vs RKRouter

所以我对这两个功能的区别有多么困惑,或者至少是如何将它们合并在一起.我有这种情况,我有这个描述符:

RKResponseDescriptor *responsePlant = 
    [RKResponseDescriptor
        responseDescriptorWithMapping:plantMapping
                          pathPattern:@"/api/rest/plants/:plant_id"
                              keyPath:nil
                          statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

现在,我想做这样的事情

RKResponseDescriptor *responsePlantAll = 
    [RKResponseDescriptor
        responseDescriptorWithMapping:plantMapping
                          pathPattern:@"/api/rest/plants/"
                              keyPath:@"objects"
                          statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

请注意,keyPath在一个地方是零,而在另一个地方则不是.

这有效…但它是很多副本粘贴.我可以使用RKRouter吗?

非常感谢!

解决方法

你调用两个不同的路径,所以使用两个不同的RKResponseDescriptor对我来说非常有意义!

I also would like to know if you can or should use RKRouter with
RKResponseDescriptor?

我真的建议使用Routes.有了它们,我的所有路径都集中在我的RKObjectManager子类中,所以如果我必须改变路径,我不必到处寻找!

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...