我了解如何对 PFObject 进行子类化,但我不确定如何在访问器中执行其他自定义代码,同时仍然调用 Parse 所定义和 @dynamic-ally 添加的该访问器的通用实现(根据属性的类型,例如 PFRelation 等)。
例如...
// MyPFObjectSubclass.h
#import <Parse/Parse.h>
@interface MyPFObjectSubclass.h : PFObject<PFSubclassing>
@property (retain, nonatomic) id myProperty;
+ (NSString *)parseClassName;
@end
// MyPFObjectSubclass.m
#import "MyPFObjectSubclass.h"
#import <Parse/PFObject+Subclass.h>
@implementation MyPFObjectSubclass
@dynamic myProperty;
+ (NSString *)parseClassName {
return @"MyPFObjectSubclass";
}
- (void)setMyProperty:(id)someProperty {
// insert some custom code here, e.g. for validation...
// call the generic, dynamic implementation of setMyProperty, but how?
// obviously, you cannot call [super setMyProperty:someProperty];
}
@end
任何帮助表示赞赏。