ios - Is it correct to save custom core data object using managedObjectContext property -
i have managed object in core data. custom object necessary managed properties. want know if correct if call save method using managedobjectcontext property of same object? when create object pass managedobjectcontext initializer. object saves passed context in property?
let appdelegate = uiapplication.shared.delegate as! appdelegate let context = appdelegate.persistentcontainer.viewcontext let entity = nsentitydescription.entity(forentityname: "message", in: context) let message = popmessage(entity: entity!, insertinto: context)
now after modifying properties can call this?
message.managedobjectcontext.save()
i find more convenient not sure if give desired results.
it fine. both contexts point same object , result same. issue aware of managed object not keep strong pointer context. if context has left memory have problems. can happen if create context without assigning variable, or pass around managedobject blocks.
Comments
Post a Comment