Memory leak found with clang but cant release and autorelease crashes

Posted by Rudiger on Stack Overflow See other posts from Stack Overflow or by Rudiger
Published on 2010-03-15T00:00:37Z Indexed on 2010/03/15 0:09 UTC
Read the original article Hit count: 542

Filed under:
|
|

I have a class that builds a request based on a few passed in variables. The class also has all the delegate methods to receive the data and stores it in a property for the calling class to retrieve.

When the class initializes it creates a connection and then returns itself:

NSURLConnection *connection;
if (self = [super init]) {
    self.delegate = theDelegate;
    ...some code here...
    connection = [[NSURLConnection alloc] initWithRequest:theRequest  delegate:self  startImmediately:YES];
}
return self;

So I can't release it normally and if I autorelease it crashes. Is it the job of the calling class to release? And if so does just releasing the initilised object also release connection or do you have to release it specifically? If so how would you?

Thanks

© Stack Overflow or respective owner

Related posts about clang

Related posts about iphone