code structure
@protocal A_Delegate
{
-(void)doIt:(BOOL)isDone;
}
Super Class A // has properties of set delegate
-(void) setDelegate:(id<A_Delegate>)_delegate
{
/*self.delegate = _delegate*/ error, compiler stops right there and doesn't assigns the value from '_delegate'
self.delegate = _delegate.
//should be
delegate = _delegate;
}
Sub Class B : A // want to call and define the delegation for the super class of B which is A
-(void) acquireDelegation:(id<A_Delegate>)_delegate
{
[[super delegate] setDelegate];
}
Now, the Class C want to use the Class B and want to know its state,
Class C : NSObject <A_Delegation>
-(void) doSomething
{
B *b = [[B alloc]init];
[b aquireDelegation:self];
}
-(void)doIt:(BOOL)isDone
{
if(isDone)
// Do Something
}
Does any body know What I have done wrong and why super can’t delegation?
Is it possible to fix?
resolved.
This would lead to infinite loop (until the stack overflow):
cause
self.delegate = _delegate;is callingsetDelegate:. You have to assign to the ivar itself.And I think this is not compiler. It is everything in runtime…