Let's say I have a class Animal
class Animal: NSObject {
var name: String = ""
var weight: Double = 0
}
In my view controller #1, I have an array of these objects:
class ViewController1: UIViewController {
var animals: [Animal] = [ .... ]
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let v = segue.destination as? ViewController2 {
v.mammals = self.animals.filter(...) // Are my objects duplicated?
}
}
}
class ViewController2: UIViewController {
var mammals: [Animal] = [ .... ]
}
Are my Animal
objects duplicated when I filter them from VC1 and pass a subset of them to VC2? When I go back from VC2 to VC1 (i.e. popping the navigation stack), are the objects in mammals
deallocated, freeing memory?
EDIT: Will this create any retain cycle of any kind??