ios - Rest kit RKMappingOperation do not work -


rest kit rkmappingoperation not work

here code run. should create data in cvvname object . not work. how make work?

class cvvname: nsobject{     var firstname = ""     var lastname = "" }   class cvvmappingprovider: nsobject {     class func namemapping() -> rkmapping     {         let resultmapping : rkobjectmapping = rkobjectmapping(forclass: cvvname.classforcoder())         resultmapping.addattributemappingsfromdictionary(["firstname":"firstname", "lastname": "lastname"])         return resultmapping     } }  func dorestkit()     {         var themapping:rkmapping = cvvmappingprovider.namemapping() let therepresentation = [["firstname": "firstname01"] ,["lastname": "lastname01"] ]         let thedestinationobject = cvvname()         let themappingoperation = rkmappingoperation(sourceobject: therepresentation, destinationobject: thedestinationobject, mapping: themapping)         {             let thetry = try themappingoperation.performmapping()             //themappingoperation.start()         }         catch nserror {             // unexpected error!         }     print("thedestinationobject \(thedestinationobject) + \(thedestinationobject.firstname) + \(thedestinationobject.lastname) +") } 

it prints empty strings

thedestinationobject <ap01.cvvname: 0x7c20f260> +  +  + 

i want print values

thedestinationobject <ap01.cvvname: 0x7c20f260> +   firstname01 +  lastname01 + 

looks problem in source data you're supplying:

let therepresentation = [["firstname": "firstname01"] ,["lastname": "lastname01"] ] 

this array of dictionaries, should supplying single dictionary of details because operation expecting single item in , single item out. consider:

let therepresentation = ["firstname": "firstname01", "lastname": "lastname01"] 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -