解析 PFQuery 包含密钥不起作用

Parse PFQuery Include key not working

我有一个class,商家:

header:

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>

@interface Business : PFObject <PFSubclassing>

+ (NSString *)parseClassName;
@property (retain) NSString *name;
@property (retain) NSString *shortName;
@property (retain) PFFile *logo;
@property (retain) PFFile *banner;

@end

实施:

#import "Business.h"
#import <Parse/PFObject+Subclass.h>

@implementation Business

@dynamic name;
@dynamic shortName;
@dynamic logo;
@dynamic banner;

+ (NSString *)parseClassName
{
    return @"Business";
}

@end

还有一个class,关系

header:

#import <Parse/Parse.h>
#import "Business.h"

@interface Relation : PFObject <PFSubclassing>

@property (retain) PFUser *user;
@property (retain) Business *business;

@end

实施

#import "Relation.h"
#import <Parse/PFObject+Subclass.h>

@implementation Relation

@dynamic business;
@dynamic user;

+ (NSString *)parseClassName
{
    return @"Relation";
}

@end

我正在进行关系查询,希望找到与特定用户相关的企业,例如:

PFQuery *query = [Relation query];
[query includeKey:[Business parseClassName]];
[query whereKey:@"user" equalTo:[PFUser currentUser]];

[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    NSMutableArray *businesses = [NSMutableArray array];
    if (objects.count) {
        for (Relation *relation in objects) {
            [businesses addObject:relation.business];
        }
    }

    block(businesses, objects, error);
}];

看来我确实成功检索到了我想要检索的商家。但是,Business class 似乎缺少某些列。我确保使用 PFQuery 的包含键,以便业务 class 将 return 它的所有属性,但它似乎包含的唯一 属性 是它的 object ID .

(lldb) po businesses <__NSArrayM 0x174050b60>( <Business: 0x170118810, objectId: 7Sdh8a0d8, localId: (null)> { } )

抱歉,我包含了太多代码,我只是觉得我的错误可能在任何地方。为什么我的查询 return 没有完整的业务 object?

谢谢!

啊,我是傻了。都在

[Business parseClassName]

我请求密钥 "Business" 而不是 "business"