NSURLConnection Leaks — Why?

As the comment from roe said, you are allocating the connection (retain count 1) and then retaining it again with your connection property (retain count 2). You only release once in the delegate selectors. You have two options.

As the comment from roe said, you are allocating the connection (retain count 1) and then retaining it again with your connection property (retain count 2). You only release once in the delegate selectors. You have two options: 1) Change your connection property to assign rather than retain.

@property (nonatomic, assign) NSURLConnection *connection; // OR, since assign is the default you may omit it @property (nonatomic) NSURLConnection *connection; 2) Release the allocated object after it is retained by your connection property: NSURLRequest *request = NSURLRequest alloc initWithURL:_url; NSURLConnection *connection = NSURLConnection alloc initWithRequest:request delegate:self; self. Connection = connection; connection release; request release; Option 2 is preferred since there is less of a chance for leaks since alloc and release are as close together as possible. Also, if you forget to release the previous connection the synthesized methods will release the previous one for you.

Don't forget to release self. Connection in dealloc.

Thanks very much! – TomH Jan 14 '10 at 14:42 Oops I meant to say "as roe said. " Glad to help.

– James Wald Jan 15 '10 at 3:12.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions