【发布时间】:2017-08-09 23:15:02
【问题描述】:
在 Heroku 上解析服务器(当然是开源版本)。
这是我的 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"
);
}
不过,数据库中没有为我保存任何内容。我想知道我哪里做错了?
【问题讨论】:
-
改用
saveInBackground { (success, error) in ... }并在其中打印成功和错误 -
谢谢@nathan。所以这给了我以下错误,所以我发现我的初始代码“step_object.add”是错误的。确实,输入新对象的正确方法是不同的,我将其发布在我的答案中。我回来的错误是:预期的字符串但得到了数组” UserInfo={code=111,temporary=0,error=schema mismatch for driver_steps.step_string; 预期的字符串但得到了数组,NSLocalizedDescription=schema mismatch for
-
使用下标 (
step_object["step_string"] = "Was directed to drive to first location") 设置对象的属性或者更好的是,子类化。 -
没错。我只是将其发布为我的答案。再次感谢,一切顺利!
标签: swift heroku parse-platform