Swift making copies of passed class instances

Viewed 3216

I have an init that takes in an instance of a class (which I hope everyone knows that that means it's pass-by-reference)

I want to be able to copy the object and store in on two class instance variables, such that, I have a function that is meant to act as a "reset" where it will set any changes I had made up to a certain point go back to what it was before.

so something like:

convenience init(_ item:Item?){
    self.init()
    self.item = item
    self.undoItem = item
}


func reset(){
    self.item = self.undoItem
    self.reloadInfo()
}

I haven't had much success with what should be a relatively straight forward solution. I'm just too new to Swift and iOS development.

2 Answers
Related