Swift RestKit问题

时间:2016-02-05 02:40:16

标签: swift2 restkit mlab

我在Swift应用程序中安装了RestKit。我找不到好的文档来让它在swift中工作。这就是我所拥有的。我也从未使用过rest API。我正在连接到MongoLab。

class Users: NSObject {
  var users: String = ""
  var url : String = ""
}

let mapDict = ["users":"users","url":"url"]

class ViewController: UIViewController {

override func viewDidLoad() {

    let objectManager = RKObjectManager(HTTPClient: client)

    let mapDict = ["news":"news","url":"url"]
    let usersMapping = RKObjectMapping(forClass: Users.self)
    usersMapping.addAttributeMappingsFromDictionary(mapDict)

    let responseDescriptor:RKResponseDescriptor = RKResponseDescriptor(mapping: usersMapping,
        method: RKRequestMethod.GET,
        pathPattern: dburl,
        keyPath: nil,
        statusCodes: NSIndexSet(index: 200))

    let response = RKResponseDescriptor(mapping: usersMapping, method: RKRequestMethod.GET, pathPattern: dburl, keyPath: nil, statusCodes: NSIndexSet(index: 200))

    RKObjectManager.addResponseDescriptor(response)

有人能引导我朝正确的方向前进吗?

0 个答案:

没有答案