保存后如何立即检索objectId [英] How to retrieve objectId right after save
本文介绍了保存后如何立即检索objectId的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Unity和Parse.com进行游戏开发.我试图弄清楚保存后是否立即检索了objectId.我已经尝试过了:
I am using Unity and Parse.com for my game development. I am trying to figure out I retrieve the objectId right after save. I have tried this:
ParseObject myGame = new ParseObject("Games");
myGame["score"] = 223;
myGame["playerName"] = "Michael";
Task saveTask = myGame.SaveAsync().ContinueWith(t => {
ParseObject theObject = t.Result;
string newObjectId = theObject.objectId;
});
我在t.Result上收到一条错误消息:
I get an error on the t.Result saying:
Type `System.Threading.Tasks.Task' does not contain a definition for `Result' and no
extension method `Result' of type `System.Threading.Tasks.Task' could be found (are
you missing a using directive or an assembly reference?)
可以通过这种方式或其他方式完成此操作.
Can this be done in this way or another.
感谢您的任何帮助,并在此先感谢:-)
any help is appreciated and thanks in advance :-)
推荐答案
我在检索新创建的ObjectId
时也遇到了问题.经过几个小时(和大量的搜索),我能够使下面的代码起作用:
I was also having problems with retrieving the newly created ObjectId
. After a few hours (and a lot of searching) I was able to get the below code to work:
public static async Task<string> CreateNewGame()
{
string newObjectId = null;
ParseObject myGame = new ParseObject("Games");
myGame["score"] = 223;
myGame["playerName"] = "Michael";
await myGame.SaveAsync().ContinueWith(
t =>
{
newObjectId = myGame.ObjectId;
});
return newObjectId;
}
这篇关于保存后如何立即检索objectId的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文