Parse文档特别声明您不应该为PFObject的子类重写init。这对于在代码中创建的对象是可以的,因为你可以覆盖对象方法,就像这样......
@implementaion CustomObject : PFObject <Subclassing>
+ (instancetype) object {
CustomObject *me = [super object];
// init some instance variables or whatever
return me;
}
@end
这适用于本案例: CustomObject * myThing = [CustomObject object];
但是从查询中获取对象时似乎没有调用对象....
PFQuery *query = [CustomObject query];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for(int i = 0; i < objects.count; i++){
CustomObject *myThing = objects[i];
// object method was never called...
}
}
}];
那么......如何在获取自定义PFObject时初始化它?
答案 0 :(得分:1)
可能您还没有注册子类。
只需在
之前致电[CustomObject register]
[Parse setApplicationId:@"your id"
clientKey:@"your key"];
或添加到子类
+ (void) load{
[self register];
}