I am trying to update a record in Backendless using the following code but getting crash when I am storing result as CompanyKey.
let dataQuery = BackendlessDataQuery()
dataQuery.whereClause = "key = '\(txtReedemCode.text!)'"
var error: Fault?
let bc = Backendless.sharedInstance().data.of(CompanyKey.ofClass()).find(dataQuery, fault: &error)
if error == nil {
if(bc.data.count == 0){
showAlert(self, title: kAppName, message: "No Matching Key Found")
}else{
for info in bc.data as! [CompanyKey] { //*****CRASHING HERE*****
print("Key - \(info.key!)")
if(info.keyStatus == "Active"){
showAlert(self, title: kAppName, message: "This key has been already used")
}else{
let dataStore = backendless.data.of(CompanyKey.ofClass())
info.keyStatus = "Active"
let result = dataStore.save(info, fault: &error) as? CompanyKey
print("\(result!.objectId!)")
}
}
}
}
else {
print("Server reported an error: \(error)")
}
The result I am getting is as following:
(
{
“___class” = CompanyKey;
“__meta” = “{“relationRemovalIds”:{},“selectedProperties”:[“companyId”,“keyStatus”,“created”,”___class",“ownerId”,“updated”,“key”,“objectId”],“relatedObjects”:{}}";
companyId = Zoi4eY4Hx8;
created = “2016-05-19 20:15:22 +0000”;
key = aWwu8U;
keyStatus = Deactive;
objectId = 4geBpGeRO8;
ownerId = “<null>”;
updated = “2016-06-29 12:51:45 +0000”;
}
)
I am not sure what’s wrong in my code.
One more point - When I use the same code running directly in my devices, I am getting no crash but when I am creating a deployment build, the same code is crashing.
Any help is highly appreciated as I would like to complete this project.
Thanks
What’s the text of an error you receive on crash?
On crash, you generally don’t receive anything.
Get this information from Crashlytics - _ArrayBuffer._getElementSlowPath(Int) -> AnyObject
Hi Rajat,
Please provide your AppId and CompanyKey class here or to support@backendless.com. We need to copy/paste your CompanyKey class to our test project for investigating this issue.
Regards,
Slava
And what do you mean saying “when I am creating a deployment build”? Ad Hoc?
I am creating development build
APP_ID = “A3A78064-5006-A4B8-FF85-3ECB7637DC00”
SECRET_KEY = “00CA23B1-40B1-A73B-FF91-AD094D4E7C00”
Company Class Detail Method
class CompanyKey : NSObject {
var companyId : NSString!
var key : NSString!
var keyStatus : NSString!
var objectId : NSString!
var ownerId : NSString!
}
Appreciate if anyone from Backendless will provide a solution or suggest alternate approach to fix this issue. My App release is delayed because of this issue.
We are working now with this issue. We cannot reproduce it on our Backendless app, so now we are checking with your app.
Rajat, please try :
class CompanyKey : NSObject {
var companyId : String?
var key : String?
var keyStatus : String?
var objectId : String?
var ownerId : String?
}
Let me check and update you in some time.
We have created the sample project with your CompanyKey class and your fetching method (in attachment). It uses the latest Backendless SDK from CocoaPods (3.0.28 release), you should load it with TestBKNDLSS12859.xcworkspace.
We just created development build and checked it with your Backendless app (A3A78064-5006-A4B8-FF85-3ECB7637DC00). It works fine with your CompanyKey data.
Please try it with your Bundle Identifier, and let us know how it works for you with development build.
TestBKNDLSS12859.zip (19.54MB)
I will update you shortly after building and testing this build.
Rajat, do you use Testflight & Crashalytics with development build?
Yes, We have integrated Crashalytics in development build.
And We have still problem.
To be precise, we are using Crashlytics and deploy development builds using Diawi platform that is similar to Fabric or Test flight.
I have integrated your code in my App to check the solution. But I am facing the same crash. Here is what I have received over Crashlytics email.
“New fatal issue in APP
UpgradeViewController.swift line 0
specialized _ArrayBuffer._getElementSlowPath(Int) -> AnyObject”
Appreciate if you could provide a proper fix today itself.
Thanks
Hi Rajat,
Why do you think what this Crashlytics message is associated with the line:
for info in bc.data as! [CompanyKey] { //*****CRASHING HERE*****
I don’t sure.
We have created the sample project with Crashlytics and checked development build with your Backendless app (A3A78064-5006-A4B8-FF85-3ECB7637DC00). It works for us - any crashes. So, we cannot reproduce this issue - and we cannot fix it.
Could you try a development build of attached project with your Bundle Identifier? How it will work for you?
Another way is to provide your full project which demonstrates the problem to support@backendless.com (you could upload it to Dropbox or Google Drive), and we will investigate it.
Regards,
Slava
TestCrashlytics.zip (29.86MB)
I am just out of ideas for this issue. I have been through the same crash while updating few records but for the interest of time, I replaced the update call with delete + add.
For this particular scenario, I don’t have that option and stuck with it for quite a long time. If you are developer then I am sure you can understand my frustration.
Anyways, I need some time to build and check your sample. I will provide you update on this tomorrow. If it will not work then I will share my code over DropBox or Drive over support email.
Thanks
Rajat,
We definitely understand your frustration. The sooner we can get to the point when we can reliably reproduce the crash, the sooner we can create a fix. If you have a project which demonstrates the crashes, please package/zip and send it to support@backendless.com (with the zip file uploaded somewhere (g.drive or dropbox).
Regards,
Mark
The sample you provided is also crashing for us. If you could share you UDID, I can provide you a build to check on your iOS device.
Thanks