tags:

views:

51

answers:

3

According to Apple if one doesn't create an object using alloc or new then it does not need to be released.

Is my understanding correct? So something like this does not need to be released:

NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];
+1  A: 

If a method name contains new, alloc, or copy, you must release it.

You do not need to release the NSURLRequest in your example, it is autoreleased.

Jacob Relkin
`init` does not belong to the set. It is just usually used in conjunction with `alloc`.
Nikolai Ruhe
Nikolai is right .. `init` does *not* belong to this set.
Max Seelemann
A: 

Correct. You would not release that object. The only time you would is if you had first retained it (i.e taken ownership of it).

Simon
+2  A: 

Apple`s Memory Management Rules:

You take ownership of an object if you create it using a method whose name begins with “alloc” or “new” or contains “copy”

So: You are right.

Nikolai Ruhe