我理解如何子类化PFObject,但我不确定如何在访问器中执行其他自定义代码,同时仍然按照定义调用该访问器的通用实现,并通过Parse添加@动态 - 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
感谢任何帮助。
答案 0 :(得分:0)
您需要做的就是实现自己的访问者并跳过@dynamic