Re: (no subject)
Re: (no subject)
- Subject: Re: (no subject)
- From: Uli Kusterer <email@hidden>
- Date: Sat, 7 Oct 2006 12:08:29 +0200
Am 07.10.2006 um 10:30 schrieb Hans van der Meer:
The following code unarchives an item stored on a stack:
/* Unarchive the stack top. */
stacktop = [NSKeyedUnarchiver unarchiveObjectWithData:[stack
lastObject]];
By looking at the retainCount of stacktop I conclude that the
object returned by NSKeyedUnarchiver is returned autoreleased.
However, I cannot find this mentioned in the documentation.
*never* look at the retain count. Look at the method name. The list
rules tell us not to restate the memory management rules here, so
I'll point you at the docs:
<http://devworld.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/
Tasks/MemoryManagementRules.html>
Note that "take ownership" means you release it, while if someone
else has ownership, it means that it's either autoreleased or owned
by another object. The latter case is worth mentioning since e.g.
NSArray owns all of its objects, and when you release an NSArray, the
objects in it are generally released as well. So, request ownership
using retain (and later release it) if you need an object you don't
own longer than the owner exists, or longer than the current
autorelease pool exists.
Is my conclusion correct or am I mistaken and is this not correct?
Please, can someone corroborate.
The conclusion is correct, but the method by which you arrived at
it was wrong. That clarify things? :-)
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >(no subject) (From: Hans van der Meer <email@hidden>) |