gpt4 book ai didi

swift - 解析添加对象不起作用

转载 作者:行者123 更新时间:2023-11-28 15:23:26 24 4
gpt4 key购买 nike

Heroku 上的解析服务器(当然是开源版本)。

这是我在 swift 中的 iOS 代码。我必须说 Parse SDK 运行良好。我可以查询其他表并做很多事情,所以我知道那部分没问题。到目前为止,我一直只查询现有数据,但今天我第一次尝试向表中添加内容,但遇到了困难。

以下是我的代码:

let step_object = PFObject(className: "driver_steps")
step_object.add("Was directed to drive to first location", forKey: "step_string")
step_object.saveInBackground()

打印到控制台的对象对我来说看起来不错:

print("the object is \(step_object)")

输出:

the object is <driver_steps: 0x1844b54e0, objectId: new, localId: (null)> {
ACL = "<PFACL: 0x18043f720>";
"step_string" = (
"Was directed to drive to first location"
);
}

虽然数据库中没有为我保存任何内容。我想知道我哪里做错了吗?

最佳答案

使用 Parse SDK 添加完整新对象的正确方法与我的问题不同。应该是这样的:

let step_object = PFObject(className: "driver_steps")
step_object["step_string"] = "Was directed to drive to first location"
step_object.saveInBackground()

关于swift - 解析添加对象不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45602032/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com