I have an instance of Addon
class (inherited from NSManagedObject
) foundSampleAddon
. I want to create a copy of this instance of class and mutate its properties. I am trying to copy this instance using the following code but I am not sure how to achieve it as I am getting an exception
-[Addon copyWithZone:]: unrecognized selector sent to instance 0x7f9d1d805000
I dont know how to create copy of this instance of class using the copyWithZone:
function. I have posted the code below where I am trying to copy foundSampleAddon
into a new identity, sampleAddonToAdd
and then changing its property productAddonPrice
.
if let sampleAddonToAdd = foundSampleAddon.copy() as? Addon {
if addonCategoriesSent![sentIndexPath!.section].replacePreviousBasePrice == 1 {
sampleAddonToAdd.productAddonPrice = NSNumber(int: 0)
}
addonsToAddBackToProduct.append([keyAnAddon: sampleAddonToAdd, keyAddonCount: 1])
}