How mapping this json using restkit in swift? or objective-c? Only not use coredata.
[{"one":"1","two":"2","three":"3","four":"4"}, {"one":"1","two":"2","three":"3","four":"4"}, {"one":"1","two":"2","three":"3","four":"4"}]
I have this code, but it's not work.
let postMapping: RKObjectMapping = RKObjectMapping(for: GetAddress.self)
postMapping.addAttributeMappings(from: ["one", "two", "three", "four"])
let statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClass.successful)
let resDescriptor = RKResponseDescriptor(mapping: postMapping, method: RKRequestMethod.GET, pathPattern: "/test", keyPath: nil, statusCodes: statusCodes)
let url = NSURL(string: "http://test.com/path")
let addURL = "test/code"
let objectManager = RKObjectManager(baseURL: url as URL!)
objectManager?.addResponseDescriptor(resDescriptor)
objectManager?.getObjectsAtPath(addURL, parameters: nil,
success: { operation, mappingResult in
let post: GetClass = mappingResult!.firstObject as! GetClass
print("one: \(post.one!)")
print("two: \(post.two!)")
},
failure:{ operation, error in
print("Error loading metric list': \(error!.localizedDescription)")
}
);