当我尝试从 iOS 中的本地数据存储中获取记录时,对象正在返回,但如果我访问自定义属性,它会给出错误"-[PFObject name]: unrecognized selector sent to instance"。下面是一个示例代码片段。
PFQuery *query = [PFQuery queryWithClassName:@"GameScore"];
[query fromPinWithName:@"MyChanges"];
[[query findInBackground] continueWithBlock:^id(BFTask *task) {
NSArray *scores = task.result;
for (GameScore *score in scores) {
NSLog(@"score is : %d %d", score.highScore, score.name);
}
}];
我的子类就像
@interface GameScore : PFObject <PFSubclassing>
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSNumber *highScore;
@end
我将它们保存为
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error){
[GameScore pinAllInBackground:objects withName:@"MyChanges" block:^(BOOL succeeded, NSError *error) {
}];
}];