I have a subclass A
of a Parse PFObject
defined as (details left out):
@interface A : PFObject <PFSubclassing>
@end
@implementation A
+ (void)load {
[self registerSubclass];
}
+ (NSString *)parseClassName {
return NSStringFromClass([self class]);
}
@end
I need a subclass B
of A
, defined as
@interface B : A <PFSubclassing>
@end
@implementation B
+ (void)load {
[self registerSubclass];
}
+ (NSString *)parseClassName {
return NSStringFromClass([self class]);
}
@end
A
and B
are registered in the AppDelegate by
[A registerSubclass];
[B registerSubclass];
I am not sure if this is the correct way to define subclasses of subclasses of PFObject
:
https://www.parse.com/questions/what-does-this-error-mean-subclasses-of-subclasses-may-not-have-separate-parseclassname-definitions suggests that one should not define + (NSString *)parseClassName
in subclass A
, only in subclass B
.
But if I do so, I get an error +[A parseClassName]: unrecognized selector sent to class
when A
’s registerSubclass
method is called.
When I also leave out the + (void)load
method of subclass A
, and the call to [A registerSubclass]
in the AppDelegate, the app seems to work.
So my question is:
Is it correct, to use only for the subclass at the lowest level <PFSubclassing>
, + (NSString *)parseClassName
, + (void)load
, and register it in the AppDelegate, or which is the right way to do it?
To answer my own question; maybe this helps others (I have now used the following setup for 2 weeks, and everything seems to work fine):
If one has subclasses of PFObject
subclasses, only for the lowest subclass in the hierarchy one has to do the following:
PFSubclassing
and implement +(void)load
and +(NSString *)parseClassName