But the list I retrieved with the query cannot be casted into the type.
let dataStore = backendless.data.of(Found.ofClass())
let result = dataStore.findFirstFault(&error)
let found = result as! Found // This failes
if error == nil {
print("Result: \(result)")
print("Found: \(found.objectId)")
}
else {
print("Server reported an error: \(error)")
}
let dataStore = backendless.data.of(Found.ofClass())
let result = dataStore.findFirstFault(&error)
if error == nil {
print("Result: \(result)")
}
else {
print("Server reported an error: \(error)")
}
let found = result as! Found // This failes
print(found.objectId)
class Found : NSObject {
var objectId: String?
var postUrl: String?
var imgUrl: String?
var foundLocationStr: String?
var gender: String?
var created: NSDate?
var updated: NSDate?
got the code you posted in this topic and put into a blank, brand-new project
put your app id and secret key
ran the app.
Worked exactly as expected - no errors whatsoever:
http://support.backendless.com/public/attachments/973cf4ee39cc55f3dc14207da523dee8.png</img>
This confirms that API is working properly and the error you experience is caused by something else. You can try creating a new project and isolate the use-case to that method and see if it works
I found the problem.
In the Info.plist file. I have Bundle Identifier and Bundle Name as plan strings. If I change them to
$(PRODUCT_NAME) and $(PRODUCT_BUNDLE_IDENTIFIER) , then I can cast!
Why is that?
We used “Bundle name” to determine full type name for the classes used in the app. This is no longer required. The latest lib in github contains a change that removes the requirement for having Bundle name as $(PRODUCT_NAME)