• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: retain count (Re: half-initialized objects during decoding (Re: Persistance))
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >retain count (Re: half-initialized objects during decoding (Re: Persistance)) (From: email@hidden)

  • Prev by Date: NSDocument-based application with NSTextView
  • Next by Date: Re: NSException and Java Exception
  • Previous by thread: retain count (Re: half-initialized objects during decoding (Re: Persistance))
  • Next by thread: Re: half-initialized objects during decoding (Re: Persistance)
  • Index(es):
    • Date
    • Thread