Hello, I have a class “Record” which have 2 relationships, “User” and “Oversight”, I’m doing this:
let dataStore = self.backendless.data.of(Record.ofClass())
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
let dataStore = self.backendless.data.of(Record.ofClass())
if let savedUserRecord = dataStore.save(userRecord) as? Record {
dataStore.setRelation("oversight", parentObjectId: savedUserRecord.objectId, childObjects: [oversight])
dataStore.setRelation("user", parentObjectId: savedUserRecord.objectId, childObjects: [user])
dispatch_async(dispatch_get_main_queue()) {
success()
}
}
}
I’m using this setup:
- Xcode 8.0
- Swift 2.3
- pod ‘Backendless’, ‘~> 4.0’
The setRelation method is giving me an strange error and the app crashes. I don’t have constraints in those related objects. The error is this: “libc++abi.dylib: terminating with uncaught exception of type Fault”
Any idea of what could be wrong?
Thank you!
Please provide your APP_ID.
Regards, Olga
APP_ID: B5722E16-56D9-8786-FFAA-5690E006ED00
Thanks!
First of all - you are able to handle the Fault exception of sync methods with @try -@catch. Please check this doc for more info.
Then, please rename your description column of the Record table, because getter for ‘description’ with Objective-C selector ‘description’ conflicts with getter for ‘description’ from superclass ‘NSObject’ with the same Objective-C selector (I’ve tested in Xcode 9, Swift 4).
Secondly, you can use async methods without dispatch if you want. Please check this doc - you can find the async methods examples there.
Also, please notice that childObjects is the array of objectIds, not objects.
Regards, Olga
Thank you Olga for your prompt response! My error was that I was using the object directly instead of the object id, I did the migration for Android last week and there I was using the object instead of the object id and probably that mixed me up.
About the async methods, I know about them, actually I’m using them but I was trying different ways to find the error.
Thank you very much!
Glad my answer helped you!
Regards, Olga