RestKit RKObjectMapping映射一个简单的根数组

时间:2016-08-15 13:14:15

标签: swift restkit rkobjectmapping

对于简单的对象响应

{"api_key": "cool api key"}

我像这样使用RKObjectMapping

class APIRegisterResult: NSObject {
    var api_key: String = ""
}


let registerMapping : RKObjectMapping = RKObjectMapping(forClass: APIRegisterResult.self)
registerMapping.addAttributeMappingsFromArray(["api_key"])

objectManager.addResponseDescriptor(RKResponseDescriptor(mapping: registerMapping, method: RKRequestMethod.POST, pathPattern:"register", keyPath: nil, statusCodes: NSIndexSet(index: 200)))

如何将它用于简单的数组响应?

[{"id:"cool id"},{"id":"cooler id"}]

0 个答案:

没有答案