[IOS][SWIFT] retrieving relations from user table creating an error

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 {

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.

Oh I did make sure that my class is defined as its own swift file outside the view controller.
Also, I checked on the Bundle Name and it’s set properly.

Hi Robert,

Please, update the latest Backendless SDK from CocoaPods (3.0.11) or from gihub (CommLibiOS & backendless).


That did it! Thanks!