解析fetchIfNeeded()不工作 [英] Parse fetchIfNeeded() not working

查看:204
本文介绍了解析fetchIfNeeded()不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个对象指针(指向ParseUser)我的表中的攻击。看来这些指针对象需要一段时间才能得到retrieved.Hence我的code直接没有工作,给了我异常:

I have 2 pointer objects(pointing to ParseUser) in my table "Attack".It seems these pointer objects take a while to get retrieved.Hence my code directly didnt work and gave me the exception:

 java.lang.IllegalStateException: ParseObject has no data for this key.  Call fetchIfNeeded() to get the data.

我然后做周边fetchIfNeeded功能用try-catch块要紧的:

I then did the needful surrounding the fetchIfNeeded function with a try-catch block:

ParseObject battle = null;
try {
   battle = objects.get(0).fetchIfNeeded();
} catch (ParseException e1) {
   // TODO Auto-generated catch block
   e1.printStackTrace();
}
ParseUser attacker1 = battle.getParseUser("Attacker");
Log.i("dontest",attacker1.getUsername());

它仍然返回same.I甚至与 isDataAvailable 检查功能,它返回解决这个true.Any方式?

It is still returning the same.I even checked with isDataAvailable function and it returned true.Any way around this?

P.S:我的查询返回准确的1行,我与检查大小()函数

P.S.: My query returns exactly 1 row which I checked with the size() function.

这里的文档描述fetchIfNeeded()函数。

Here's the documentation describing fetchIfNeeded() function.

推荐答案

使用您的查询这样的..

Use Your query like this..

ParseQuery<ParseObject> pQueryFromAttack = new ParseQuery<ParseObject>("Attack");
// use include to fetch details while quering----increase loading speed by doing this.
pQueryFromAttack.include("pointer to _user table");
List<ParseObject> listObj = pQueryFromAttack.find();

有关例如:

 String userName =listObj.get(0).fetchIfNeeded().getString("name");

使用像这样...

这篇关于解析fetchIfNeeded()不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆