I am having an issue with the following line of code when used in an asynchronous find method. The odd part is that it works in the synchronous version without any issues. Am I doing something wrong?
let username = user.getProperty("username") as! String
Synchronous Code
var fault: Fault?
let result = backendless.data.of(BackendlessUser.ofClass()).find(dataQuery, fault: &fault)
if fault == nil
{
if result.totalObjects.intValue == 0
{
...
}
else if result.totalObjects.intValue >= 1
{
let user = result.data[0]
let username = user.getProperty("username") as! String
}
}
else
{
// Handle Errors
}
Asynchronous Code
self.backendless.data.of(NewEmailUser.ofClass()).find(dataQuery, response: {(result : BackendlessCollection!) -> () in
if result.totalObjects.intValue == 0
{
...
}
else if result.totalObjects.intValue >= 1
{
let user = result.data[0]
let username = user.getProperty("username") as! String
}
}, error: { (fault : Fault!) -> ()in
// Handle errors.
})