Backendless Support
 
Answered

Saving an object in Swift 3 saves empty object in Backendless

Having moved a project to Swift 3 and setting up classes as inheriting from NSObject and not Backendless, as we did in the past. When I save the object async to the server, I end up with an empty line. None of the data gets across.

Is there anyone that can see what is going on?

Apologies for having to zip the file up, was wasn't allowed to attach the .swift file.

Leave a Comment

Comments (4)

photo
1

Hello Jorgen

Our iOS developer will contact you regarding the results of your code analysis. You may reference it by id 14126.

Thanks for patience.

Regards Anton

photo
1

Hi Jorgen,

Please note that the fields of types Bool, Int, Double and Float cannot be declared optional. See the note in the documentation (bottom of the page):

https://backendless.com/documentation/data/ios/data_data_object.htm

Could you please make the change and try again?

Regards,

Mark

photo
1

Hello Jorgen,

BodyTrack properties should be initialised like

  1. class BodyTrack: NSObject {
  2. var trackingDate: Date?
  3. var chest = 0.0
  4. var upperArm = 0.0
  5. var waist = 0.0
  6. var hip = 0.0
  7. var thigh = 0.0
  8. var weight = 0.0
  9. var bodyFat = 0.0
  10. var fatFreeMass = 0.0
  11. var totalBodyWater = 0.0
  12. var bodyMassFat = 0.0
  13. var smm = 0.0
  14. var objectId: String?
  15. var created: Date?
  16. var updated: Date?
  17. }

with no init() method overriding. Everything works fine then.

Regards,

Olga

photo
1

Thanks Olga. That fixed other classes I had problem with as well.