I have 2 ViewControllers, the first one has an array that is filled by a fetch request once the ViewController appears. The second ViewController has a reference to that array. However, that is referencing an empty array which before it's being filled.
I want to get a reference once the array is filled. Here is a snippet.
class VC1: UIViewController {
let coreDataObjects = [NSManagedObject]() //At this moment, this array is empty
func viewWillAppear {
fetchRequestThatFillsTheArray() //Here, the array is filled
}
fetchRequestThatFillsTheArray() {
//calling NSFetchRequest
}
}
class VC2: UIViewController {
let vc1 = VC1()
vc1.coreDataObjects //Empty array
}
Thanks.