When to release a class with delegates

Posted by Stefan Mayr on Stack Overflow See other posts from Stack Overflow or by Stefan Mayr
Published on 2010-04-02T08:16:52Z Indexed on 2010/04/02 8:33 UTC
Read the original article Hit count: 240

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c