I have a PFObject Subclass SomeClass, to which i added a method iconImageName
.h
@interface SomeClass : PFObject
@property (nonatomic, strong) NSDictionary * availableAttributes;
@property (nonatomic, strong) NSString * type;
- (NSString *)iconImageName;
@end
.m
@implementation SomeClass
@dynamic availableAttributes;
@dynamic type;
+ (NSString *)parseClassName {
return NSStringFromClass([self class]);
}
- (NSString *)iconImageName {
return [NSString stringWithFormat:@"icon-type-%@", self.type];
}
@end
but after calling
[object iconImageName]
i get
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFObject iconImageName]: unrecognized selector sent to instance 0x174133b00'
i can confirm that the object is indeed SomeClass
this also happens when i use a class method +
According to documentation you ignored some subclassing rules:
To create a
PFObject
subclass:
1. Declare a subclass which conforms to thePFSubclassing
protocol.
2. Implement the class methodparseClassName
. This is the string you would pass toinitWithClassName:
and makes all future class name references unnecessary.
3. ImportPFObject+Subclass
in your .m file. This implements all methods inPFSubclassing
beyondparseClassName
.
4. Call[YourClass registerSubclass]
before ParsesetApplicationId:clientKey:
.
Try to satisfy this rules for your class.
Example:
// Armor.h
@interface Armor : PFObject<PFSubclassing>
+ (NSString *)parseClassName;
@end
// Armor.m
// Import this header to let Armor know that PFObject privately provides most
// of the methods for PFSubclassing.
#import <Parse/PFObject+Subclass.h>
@implementation Armor
+ (void)load {
[self registerSubclass];
}
+ (NSString *)parseClassName {
return @"Armor";
}
@end