[Solved] Why it print out an empty array instead of the array appended with values for the first time in viewDidLoad()?
[ad_1] The call to API.Tag.observeTagPool is asynchronous and it will finish after fetchTagPool() has returned the empty self.tagArr. You need to change fetchTagPool to return the value through a callback function like this: override func viewDidLoad() { super.viewDidLoad() // Note: This will print AA after viewDidLoad finishes // Use trailing closure syntax to pass the … Read more