Hey all,
Having some issues.
Here is the retrieval code:
class func getUserSessions(user: BackendlessUser) -> [BLSession] {
let whereClause = "user.email = '\(user.email)'"
let dataQuery = BackendlessDataQuery()
dataQuery.whereClause = whereClause
var error: Fault?
let bc = Backendless.sharedInstance().data.of(BLSession.ofClass()).find(dataQuery, fault: &error) as BackendlessCollection
if error == nil {
print("Session have been found: \(bc.data)")
let sessionList = bc.data as! [BLSession]
return sessionList
}
else {
print("Server reported an error: \(error)")
return []
}
}
Then I do :
let sessionList = getUserSessions(backendless.userService.currentUser)
I then try to iterate over this array (it does return an array of my BLSession class)
for curSession in sessionList {
print(curSession)
}
However, I get an error :
“fatal error: NSArray element failed to match the Swift Array Element type”
Not sure where I am going wrong but clearly I am doing something wrong.
Any help is appreciated.
Rob