Problem writing query in Swift

I cant figure out how to query my data. I imported data from Parse and tries to query it.

Every try give me the same result:

var backendless = Backendless.sharedInstance()
let datastore = backendless.data.of(BackendlessUser.ofClass())
let collection = datastore.find()
let users = collection.getCurrentPage()
print("count : \(users.count)")

And it gives me this error:

“Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘*** -[__NSArray0 objectAtIndex:]: index 3 beyond bounds for empty NSArray’”

I have checked the roles and acl and NotAuthenticated, iOS User and Administrator has “Find” permission set.

Hi Johan,

Have you tried running the sample from the documentation? Does it work for you?

You could investigate this sample.

I just tried to following from the documentation example:

let backendless = Backendless.sharedInstance()
let dataStore = backendless.data.of(Name.ofClass())
var error: Fault?
        
let result = dataStore.findFault(&error)
if error == nil {
    let contacts = result.getCurrentPage()
    for obj in contacts {
        print("\(obj)")
    }
} else {
    print("Server reported an error: \(error)")
}

and it resulted in nil for the result object. I have a class matching table name:

class Name : NSObject {
    var objectId: String?
    var created: NSDate?
    var updated: NSDate?
    var name: String?  
}

And the permission for the table is find for NotAuthenticated and iOSUser roles.

Do you have a table Name on your Backendless Console?

Now I got it to work, somehow backendless.init() in my AppDelegate was deleted.

It started to work as soon as I added the app key and secret.