有一个A级课程:
@interface ClassA : NSObject {
}
@property (nonatomic, assign) id prop1;
@end
@implementation
@synthesize prop1;
@end
然后我有子类
@interface ClassB : ClassA {
}
@end
@implementation
- (id)init {
self = [super init];
if (self) {
}
return self;
}
//This is infinite loop
- (void) setProp1:(id)aProp
{
self.prop1 = aProp;
}
@end
这是无限循环,因为ClassB中的setProp1从ClassB中调用[ClassB setProp1:val].
我已经试过打电话给[super setProp1],但是这个
如何覆盖@property并在覆盖的setter中赋值?假设我不能修改ClassA.