• 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: Zeroing out instance variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zeroing out instance variables


  • Subject: Re: Zeroing out instance variables
  • From: "Paul Sanders" <email@hidden>
  • Date: Sat, 17 Apr 2010 14:53:51 +0100

> As I mentioned in my post to Graham just now, doesn't your
> implementation assume that NSObject's only ivar is the isa
> pointer,
> though?

Actually, no.  Because it makes a bitwise copy of a clean,
properly init'ed object it should work whatever trickery
NSObject (or any other parent class) does behind your back with
hidden iVars.  Something I've never been clear about though is
where an object's retain count is stored.  This obviously
requires an iVar somewhere (in addition to isA), so there might
be a trap for the unwary there, but if you ensure (or better
still assert) that a to-be-recycled object has a retain count of
1 you should be OK.  And I'm also not sure if it's valid to make
a bitwise copy of a Core Foundation object, which is what we are
doing here.  Thinking about it, probably not.

As Ken said, these tricks are probably easier to pull off in
C++, but no doubt you have an existing obj-C code base.

Paul Sanders.



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Zeroing out instance variables
      • From: Ken Thomases <email@hidden>
References: 
 >Zeroing out instance variables (From: Ben Haller <email@hidden>)
 >Re: Zeroing out instance variables (From: Graham Cox <email@hidden>)
 >Re: Zeroing out instance variables (From: Ben Haller <email@hidden>)
 >Re: Zeroing out instance variables (From: "Paul Sanders" <email@hidden>)
 >Re: Zeroing out instance variables (From: Ben Haller <email@hidden>)

  • Prev by Date: Re: Zeroing out instance variables
  • Next by Date: Re: Zeroing out instance variables
  • Previous by thread: Re: Zeroing out instance variables
  • Next by thread: Re: Zeroing out instance variables
  • Index(es):
    • Date
    • Thread