func retrieveTour(tour_id: String) -> Tour {
let whereClause = "price = 10000"
let dataQuery = BackendlessDataQuery()
dataQuery.whereClause = whereClause
var error: Fault?
let bc = backendless!.data.of(Tour.ofClass()).find(dataQuery, fault: &error)
let tour = Tour()
if error == nil {
print("+++ Sucessfully retrieved tour data.")
print(bc)
}
else {
print("Server reported an error: \(error)")
}
return tour
}
Log:
+++ Sucessfully retrieved tour data.
nil
What might be a problem? A similar user retrieval function works properly.
Are there objects in the data table which match the query?
What version of the Backendless SDK for iOS do you use?
And what is your application ID?
App ID: A19DE8C5-C6B2-3E7C-FF77-751ED56B8500
Thanks. We are looking into it.
I put together a sample project using the code you shared and am getting the value back:
<BackendlessCollection> -> type: BasicProject.Tour, offset: 0, pageSize: 100, totalObjects: 1, data: (
"<BasicProject.Tour: 0x618000246ed0>"
), query: <BackendlessDataQuery> -> properties: (null), whereClause: price = 10000, queryOptions: <QueryOptions> -> {
offset = 0;
pageSize = 100;
related = (
);
sortBy = (
objectId
);
}
The difference between my code and yours is the Tour class in my case is rather simple:
class Tour:NSObject
{
var title:String?
}
If you could share with us your Tour, Location and Category classes, we’ll be happy to give it a try .
Mark
Hey Mark,
I’ve just resolved my problem! In Tours class some variables were referring to Location, and Category classes, which attributes were not the same as in the classes defined in a database. So, when retrieving Tours even without further casting resulting object into Tours.class, the query result will be nil.
I thought that such error couldn’t happen, since I didn’t explicitly reference to Location and Category classes.
Please, add a corresponding note to a documentation, to avoid further misunderstandings from users.
Sincerely, Akhan
Hi Arkhan,
I am glad you resolved the problem. The location and category columns are marked as “auto-load” in the Tour table, as a result, those objects are returned to you as well. Backendless SDK automatically attempts to cast the objects in preparation for you using them in the app.
Regards,
Mark