coredata object mutablecopy in swift

 Problem:

I want to copy my coredata object as another object and then change the current object with new updates.After that i want to save or discra the changes.If i save the change then want to know the old object before changed.

How can i get that?

Solution:

You have to add the extension function as below to your coredata entity.

func copyObject() -> Obj {

        var newObj = Obj(context: getContext())

        var newTitle = ObjTitle(context: getContext())

        newObj.title = newTitle

        newObj.title?.name = self.title?.name

        newObj.desc = self. desc

        return newObj


    }


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift