When to release a class with delegates
- by Stefan Mayr
A quick question to delegates. Lets say, CLASSA has a delegate defined:
@protocol MyDelegate
-(void) didFinishUploading;
@end
In CLASSB I create an instance of CLASS A
-(void) doPost {
CLASSA *uploader = [[CLASSA alloc] init];
uploader.delegate = self; // this means CLASSB has to implement the delegate
uploader.post;
}
and also in CLASSB:
-(void)didFinishUploding {
}
So when do I have to release the uploader? Because when I release it in doPost, it is not valid anymore in didFinishUploading.
Thanks