Object not saving type Double(saving everything else) SWIFT IOS

Hey backendless team, hope you´re doing great.
I´ve the following class:
import Foundation
class Order: NSObject {
// MARK: Properties

var cart: String?
var price: Double?
var address: String?
var additional_details: String?
var phone: String?
var receptorName: String?
var id: Int?

}
Which im trying to save using this function:
func saveOrder(cart:[Int], price: Int, address: String, additional_details: String, phone: String, receptorName:String) {

let order = Order()
order.cart = cart.description
order.price = Double(price)
order.address = address
order.additional_details = additional_details
order.phone = phone
order.receptorName = receptorName
let dataStore = backendless.data.of(Order.ofClass())

// save object asynchronously
dataStore.save(
order,
response: { (result: AnyObject!) -> Void in
let obj = result as! Order
print(“Order has been saved: (obj.id)”)
},
error: { (fault: Fault!) -> Void in
print(“fServer reported an error: (fault)”)
})
}
The object saves everything(address, details, etc.) ok BUT the price. It´s just an empty double in my table.
I´ve checked with the debugger and the “order” object does have the correct price (a number) at the moment Im trying to save it.
Any ideas what could be happenning?

Hi Aníbal,
thank you for reporting your issue. I’ve assigned it to our iOS dev and he will contact with you soon to help you.

Regards.
Stanislav

Hi! Could you try with following class:

class Order: NSObject {
var cart: String?
var price: Double = 0.0
var address: String?
var additional_details: String?
var phone: String?
var receptorName: String?
var id: Int = 0
}

Hey Kate, it´s working now :slight_smile: Could you explain me why setting price : Double = 0.0 makes a difference?

Thanks a lot!