本文介绍了Parse.com关系查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下表格名称"aniStudii"和"discipline",我也制作了屏幕截图:

I have the following tables name "aniStudii" and "discipline", I have made a screenshot as well:

如您所见,这些表之间的关系在"materii"列中. "aniStudii"中带有"Anul I"列的行具有一个值,另一列具有不同的值,可以在学科"表中找到这些值.

As you can see, there is a relation between these tables, at the "materii" column. The row from "aniStudii" with the column "Anul I" has a value and the other column has a different value, values that can be found in the "discipline" table.

我正在使用此查询来获取值,但我得到的只是错误:键的错误指针:_p_materii(代码:106,版本:1.2.8)

I am using this query to get the values, but all I get is Error: bad pointer for key: _p_materii (Code: 106, Version: 1.2.8)

这是我的查询:

PFQuery *query = [PFQuery queryWithClassName:@"aniStudii"]; //1
PFObject *aniStudiu = [PFObject objectWithClassName:@"discipline"];
[query whereKey:@"materii" equalTo:aniStudiu];

[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
    NSLog(@"%@",results);
}];

问题出在哪里?预先非常感谢.

Where is the problem? A big thanks in advance.

推荐答案

执行以下操作,从指定的对象开始(可能需要查询才能找到):

Do something like this, where you start from a specified object (which you may need a query to find):

PFObject *sourceObject = ...;

PFRelation *relation = [sourceObject relationforKey:@"materii"];

[[relation query] findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
    NSLog(@"%@",results);
}];

要获取第一个对象,您可以执行以下查询:

To get the first object you can perform a query something like:

PFQuery *query = [PFQuery queryWithClassName:@"aniStudii"];
[query whereKey:@"numeAn" equalTo:@"######"];

这篇关于Parse.com关系查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 03:51
查看更多