2015-01-14 62 views
3

我有一個類,經營範圍:解析PFQuery包括鍵不靈

頭:

#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 

和A類,關係

頭:

#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類缺少一些列。我確保使用PFQuery的包含密鑰,這樣Business類將返回其所有屬性,但似乎包含的唯一屬性是其對象ID。

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

對不起,我已經包含這麼多的代碼,我只是覺得我的錯誤可能在任何地方。爲什麼我的查詢沒有返回完整的Business對象?

謝謝!

回答

1

啊,我當時很蠢。這是所有在

[Business parseClassName] 

我請求鍵「業務」,而不是「生意」

+1

是的,很清楚,'includeKey:'需要的列名。 –