我使用的是Swift代码,这段代码能够在解析中存储数据,但它不会将数据放在同一行,如果你能给我一些反馈的话,因为我是一个自我思考和编程初学者。谢谢。

let newTransObject:PFObject = PFObject(className: "Transaction")
let pickUpTimeObject:PFObject = PFObject(className: "Transaction")
let cityObject:PFObject = PFObject(className: "Transaction")

//将文本键设置为messageTextField的文本
newTransObject["pickup_location"] = self.myAddress.text
pickUpTimeObject["pickup_time"] = self.myTime.text
cityObject["pickup_city"] = myPlacement.locality

//保存PFObject
newTransObject.saveInBackground()
pickUpTimeObject.saveInBackground()
cityObject.saveInBackground()


self.myAddress.text = "\(myPlacement.locality!) \(myPlacement.administrativeArea!) \(myPlacement.postalCode!) \(myPlacement.ISOcountryCode!)"
self.myAddress.backgroundColor = UIColor.whiteColor()



[enter image description here][1]print("\(myPlacement.locality!) \(myPlacement.administrativeArea!) \(myPlacement.postalCode!) \(myPlacement.ISOcountryCode!)")

最佳答案

你需要创建一个PFObject并设置它的变量。我没有导入Parse,所以希望没有错误。

let newTransObject = PFObject(classname: "Transaction")

newTransObject["pickup_location"] = self.myAddress.text
newTransObject["pickup_time"] = self.myTime.text
newTransObject["pickup_city"] = myPlacement.locality

newTransObject.saveInBackground()

10-07 18:40