Re: retain count (Re: half-initialized objects during decoding (Re: Persistance))
Re: retain count (Re: half-initialized objects during decoding (Re: Persistance))
- Subject: Re: retain count (Re: half-initialized objects during decoding (Re: Persistance))
- From: "Marco Scheurer" <email@hidden>
- Date: Thu, 11 Oct 2001 15:42:28 +0200
On Thu, 11 Oct 2001 09:07:04 -0400
email@hidden wrote:
>
> Why is initWithCoder assuming that the retain count
>
should
>
> be initialized to 0? Is this how NSUnarchiver returns
>
> autoreleased objects? In that case, something like x =
>
> [[X alloc] initWithCoder:aCoder]; is also very wrong, >
>
since everybody would assume that the retain count is 1.
>
>
most likely because an internal counter at 0 is a
>
retainCount at 1. and when an object with a counter
>
at 0 receive a release, it doesn't
>
first reduce the retainCount but simply dealloc itself.
Yes that makes sense, and given the fact that init methods
are supposed "to initialize a new object (the receiver)
immediately after memory for it has been allocated" it would
make sense to also initialize the counter or retain count in
such a method. But this is still questionable when you read
the Object Ownership documentation.
Marco Scheurer
Sen:te, Lausanne, Switzerland
http://www.sente.ch