Re: Zeroing out instance variables
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