RestKit + Swift不工作

时间:2015-09-02 21:07:20

标签: ios swift restkit

我有一个Framework项目,负责与Restfull服务进行通信。我正在使用RestKit,项目编译并运行没有错误,但没有在服务器上调用,日志中没有任何内容

    RKLogConfigureFromEnvironment()

    let estrategiaMapping: RKObjectMapping = RKObjectMapping(forClass: EstrategiaDTO.self)
    estrategiaMapping.addAttributeMappingsFromArray(["id", "nome", "grp"])

    let statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClass.Successful);

    //let requestDesc = RKRequestDescriptor(mapping: estrategiaMapping, objectClass: EstrategiaDTO.self, rootKeyPath: "", method: RKRequestMethod.GET)

    let responseDesc = RKResponseDescriptor(mapping: estrategiaMapping, method: RKRequestMethod.GET, pathPattern: "/estrategias/:id", keyPath: nil, statusCodes: statusCodes)

    let url = NSURL(string: "http://localhost:3000")
    let restserver = RKObjectManager(baseURL: url)

    restserver.addResponseDescriptor(responseDesc)
    //restserver.addRequestDescriptor(requestDesc)

    RKObjectManager.sharedManager().getObjectsAtPath("/estrategias/5", parameters: nil, success: { (operation, result) -> Void in
        println(result)
        }) { (operation, error) -> Void in
            println(error.localizedDescription)
    }

更新1

我已经创建了一个新项目并成功配置了RestKit。我认为在安装和配置过程中出了问题。但现在我们好好去!

我们的想法是将数据访问层(Restfull服务)分离到一个框架中,该框架可以插入需要使用这些REST服务的项目中。

MyNormal-iOSApp - > MyDataApi-Framework - > RestKit

当我将框架“MyDataApi”导入“MyNormal-iOSApp”时,发生错误,说明在MyDataApi-Framework中尚未解析RestKit的导入。

MyDataApi-Framework优雅地编译。但是在“MyNormal-iOSApp”中使用时会出现上述错误。

如何使这项工作?

0 个答案:

没有答案