ios - How to append NSString into NSmangedobject -


i new ios development. want know 1 thing appending string nsmenged object giving me error please resolve it

here code-

let json1 = try nsjsonserialization.jsonobjectwithdata(response.data!, options:.allowfragments) let json2 = json1["interests"] as! nsarray // print(json2) var i=0; i<json2.count; i++ {     let object = json2[i] as! nsdictionary     //print(object)     let name = object["name"] as! nsstring     print(name)     self.names.append(name as! nsmanagedobject) } 

in last line getting error.

try this:

let appdel:appdelegate = uiapplication.sharedapplication().delegate as! appdelegate let context:nsmanagedobjectcontext = appdel.managedobjectcontext  let newcontact = nsentitydescription.insertnewobjectforentityforname("contact", inmanagedobjectcontext: context) newcontact.setvalue(txtname.text, forkey: "name") {    try context.save() } catch {    print("save error!") } 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -