swift - Core Data edit value with multiple entities -
i new core data , swift, have multiple entity in 1 row like
let sceneobj = scene(entity: entitydescription!, insertintomanagedobjectcontext: dbhelper .getcontext()) sceneobj.createdat = string(dictionary!["createdat"]!) let appactionsdict = dictionary!["appactions"]! as? nsarray; appactionsarray in appactionsdict!{ let entitydescription1 = nsentitydescription.entityforname("appactions", inmanagedobjectcontext: dbhelper .getcontext()) let appactionsobj = appactions(entity: entitydescription1!, insertintomanagedobjectcontext: dbhelper .getcontext()) appactionsobj.action = appactionsarray["action"] as! nsnumber? sceneobj .addobject(appactionsobj) }
here if see have "scene" entity , "appactions" "appaction" object added "scene" object.
this add part works fine stucked edit part of same.
i have done this
let fetchedresults = try dbhelper .getcontext().executefetchrequest(req) as! [scene] if fetchedresults.count > 0 { in 0 ..< fetchedresults.count { let managedobject = fetchedresults[i] managedobject.setvalue( string(dictionary!["createdat"]!), forkey: "createdat") } }
and don't how edit "appactions" in this.
please guide me how edit this.
thanks in advance
Comments
Post a Comment