iOS在获取数据时出现解析错误

时间:2014-08-11 01:51:20

标签: ios objective-c xcode nsarray parse-platform

所以,我有一个tableviewcontroller,列出了许多“配置文件”,当我点击其中一个时,我被发送到一个从segue接收objectId的viewcontroller。

if ([segue.identifier isEqualToString:@"showProfile"]) {
    ProfileViewController *profile = segue.destinationViewController;
    profile.objectId = [self.currentDog valueForKey:@"objectId"];
}

当我到达ProfileViewController时,我想使用该objectId获取配置文件数据。

PFQuery *query = [PFQuery queryWithClassName:@"dog"];
[query getObjectInBackgroundWithId:self.objectId block:^(PFObject *object, NSError *error) {
    if (!error) {
        NSLog(@"%@", object);
    }
}];

但是这部分[query getObjectInBackgroundWithId:self.objectId block:^(PFObject *object, NSError *error)正在抛出异常。

错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot do a comparison query for type: __NSArrayI'

我无法理解,无法在线找到解决方案。 在我的头文件中,我得到@property (nonatomic, strong) NSString *objectId;

1 个答案:

答案 0 :(得分:0)

你要做的是当你选择一个单元格时(从你正在使用的数组,或像你现在那样的查询)获取该单元格中的对象,并将其保存到属性“selectedObject”您可以在头文件中创建。现在,当您执行segue时,只需执行profile.objectId = self.selectedObject.objectId;