0

当我尝试从 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) {

  }];
}];
4

1 回答 1

0

我和你有完全相同的问题,在这个问题中提出并回答了它:Parse local datastore and PFObject subclasses

只需确保在使用 Parse 框架进行任何其他操作之前注册您的子类。

于 2014-12-18T20:24:12.947 回答