I have a callback function that returns an NSDictionary:
override func viewDidLoad()
{
    super.viewDidLoad()
    var nd: NSDictionary = [:]
    parseJSON(callback: {dict in
        nd = dict
        //print(nd)     This one prints the filled dictionary correctly
    })
    //print(nd)     This one prints an empty dictionary
}
I want to store the values returned from the callback function in "nd", but the print statement outside the callback is still printing an empty NSDictionary.
What am I doing wrong here, and how can I fix it?
EDIT:
var nd: NSDictionary! = nil
    override func viewDidLoad()
    {
        super.viewDidLoad()
        loadData()
        print(self.nd)
    }
    func loadData()
    {
        parseJSON(callback: {dict in
            self.nd = dict
            print(self.nd)
        })
    }
I changed it to this, so the function completes its loading, and then prints. However, the print statement in viewDidLoad() prints before the one in loadData(), and the print statement in viewDidLoad() still prints nil. Why does this happen, and what do I need to change specifically?