Here is the code:
var array:[String] = []
var second:[String] = [" "]
override func viewDidLoad() {
super.viewDidLoad()
search.delegate = self //HELP
let query = PFQuery(className: "Classes")
query.whereKey("name", notEqualTo: " ")
query.findObjectsInBackground(block: { (objects, error) in
if error != nil{
print("cannot retrieve classes")
} else {
for object in objects!{
self.array.append(object["name"] as! String)
self.second = self.array
self.classList.reloadData()
print(self.array)
}
}
})
print(second)
print(array)
}
After printing self.array, there are elements in the array, but if I just print(array) at the end, the array is still empty. Why is this? Can someone help clarify?