简体   繁体   English

创建新的PFObject时可以指定objectId吗?

[英]Can I specify a objectId when creating new PFObjects?

Swift / iOS 斯威夫特/ iOS

Can anyone tell me if it is possible to specify the PFObject objectId value when creating new objects? 谁能告诉我在创建新对象时是否可以指定PFObject objectId值?

I've obviously attempted but the save fails. 我显然已经尝试过,但是保存失败。 (which might just be the answer) (这可能只是答案)

The reason I am asking is I wondered if anyone had found a "trick" that would allow me to specify. 我问的原因是,我想知道是否有人找到了可以让我指定的“技巧”。

I am using PFObject.saveInBackground { method to persist the new object. 我正在使用PFObject.saveInBackground {方法来持久化新对象。

No you can not. 你不能。 Parse sets the objectId on the server during the save operation. 解析在保存操作期间在服务器上设置objectId。

The reason your operation is failing is because Parse is looking for an object on the server with the id that you are specifying and is then trying to update that object but it cannot find the object. 您的操作失败的原因是因为Parse在服务器上使用您指定的ID查找对象,然后尝试更新该对象,但找不到该对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何按用户对PFObject进行分组,然后对其进行排序? - How can I group PFObjects by User and then Sort them? 两个PFObject可以互相指向吗? - Can two PFObjects point at each other? XCode希望我在创建PFObject子类的新实例时指定className - XCode wants me to specify a className when creating a new instance of a PFObject subclass 创建一系列NSTextContainer时,如何根据文本内容指定容器中断? - When creating a series of NSTextContainers, how do I specify container breaks based on the text content? 如何在Swift中将Parse objectId设置为指针? - How can I set a Parse objectId as a pointer in Swift? 如何在创建新页面时解决此错误? - How can I fix this error at creating new page? 解析,如何将数组条目作为多个PFObject发送,为每个数组对象创建一个新行 - Parse, How to send array entries as multiple PFObjects, Create a new row for each array object 从 CLI 运行 swift 测试时,我可以指定平台目标吗? - Can I specify a platform target when running swift test from the CLI? 如何检索存储在PFUser.currentUser()下的PFObjects自定义子类的数组 - How do I retrieve an array of a custom subclass of PFObjects stored under the PFUser.currentUser() 如何使用Parse.com的推送通知功能更改PFObjects? - How do I use Parse.com's push notification feature for a change in PFObjects?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM