Why is my array empty after appending it? : <p>Here is the code: </p>

<pre><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)


}
</code></pre>

<p>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?</p>
