Make connection an instance variable and release it on-demand. The question "who" should release the object depends strictly on your object semantics and hierarchy.
Yeah thought of that but wanted to see if there was a convention to releasing it. – Rudiger Mar 15 '10 at 0:16 1 +1 The convention is that you retain what you care about and you release what you no longer care about. In almost every conceivable case, if you care about it, you are going to put it in an ivar.
Apple does a great disservice to new developers by not creating an ivar for NSURLConnection in their example code. It "works" because of an implementation detail of NSURLConnection, but it is confusing and sets a bad example. Use an ivar.
– Rob Napier Mar 15 '10 at 0:22 Ah k, thanks for that – Rudiger Mar 15 '10 at 0:53.
Typically, your constructor shouldn't perform this type of work. If the connection is associated to the object, I would make connection a property of the object and connection release; within the object's dealloc method.
I think it came from apples code. Thats what I thought of doing but wasn't sure if there was better convention of releasing memory like this – Rudiger Mar 15 '10 at 0:13.
Remember that you shouldn't place all your faith in Clang. It can and does report false negatives and false positives. Clang is getting better every day, but it still in its infancy right now.It's great that it's integrated with Xcode so nicely, but just keep in mind that it does have some flaws.
In this case, it depends on the scope of the variable you're storing the connection object in. If it's declared as an instance variable, then it should be ok, as long as you release it in dealloc or at some other point when you're done with it. If, like you've posted in your question, the declaration of connection is local to your init method, then Clang is correctly reporting a leak.
You should make connection an instance variable or property and ensure you release it in dealloc or when you're finished with it.
Yeah I know but I do feel it would leak. I do allocate the memory and don't release it anywhere. Though if the calling class released it clang would show an error but I would know I am dealing with it so I would ignore clang.
– Rudiger Mar 15 '10 at 0:15.
Remember that you shouldn't place all your faith in Clang. It can and does report false negatives and false positives. Clang is getting better every day, but it still in its infancy right now.
It's great that it's integrated with Xcode so nicely, but just keep in mind that it does have some flaws. In this case, it depends on the scope of the variable you're storing the connection object in. If it's declared as an instance variable, then it should be ok, as long as you release it in dealloc or at some other point when you're done with it.
If, like you've posted in your question, the declaration of connection is local to your init method, then Clang is correctly reporting a leak. You should make connection an instance variable or property and ensure you release it in dealloc or when you're finished with it.
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.