没有使用Restkit 0.27.2获得响应

时间:2018-06-07 12:04:41

标签: ios swift restkit

我使用的是Restkit 0.20.3并且运行正常。现在我将Restkit升级到0.27.2并且我没有得到任何响应请求。

这是代码

let mapping = RKObjectMapping(for: UserDetails.self)
    mapping!.addAttributeMappings(from: ["login", "name", "type"])
let statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClass.successful)
let respDescriptor = RKResponseDescriptor(mapping: mapping, method: RKRequestMethod.GET, pathPattern: nil, keyPath: nil, statusCodes: statusCodes) as Any
let request = URLRequest(url: URL(string: "https://api.github.com/users/sixpathssage")!, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)
let reqOperation = RKObjectRequestOperation(request: request, responseDescriptors: [respDescriptor])
    reqOperation!.setWillMapDeserializedResponseBlock({ (json) -> Any? in
        print(json)
        return json
    })
    reqOperation!.setCompletionBlockWithSuccess(
        { (operation: RKObjectRequestOperation!, result: RKMappingResult!) -> Void in
            print("Success")
        }, failure: { (operation: RKObjectRequestOperation!, error: Error!) -> Void in
            print("Failure")
        })
    reqOperation!.start()

在Restkit 0.27.2中是否有不同的方法来创建请求。提前谢谢。

更新 我将Restkit版本降级为0.26.0。它工作正常。不过,我不知道为什么它不适用于版本0.27.2。

0 个答案:

没有答案