Re: Accessing @private superclass ivars
Re: Accessing @private superclass ivars
- Subject: Re: Accessing @private superclass ivars
- From: Ofri Wolfus <email@hidden>
- Date: Tue, 20 Feb 2007 20:03:04 +0200
Don't do that. Use object_getInstanceVariable() or
class_getInstanceVariable() instead. @defs() is very dangerous to
work with.
- Ofri
- - - - - - - - - - - - - - - - - - -
http://www.dpompa.com
- - - - - - - - - - - - - - - - - - -
On 20/02/2007, at 01:50, Keith Duncan wrote:
On 19 Feb 2007, at 23:18, James Bucanek wrote:
Keith Duncan wrote on Monday, February 19, 2007:
I'm subclassing a class which has a private NSArray ivar containing
some objects I need access to in my subclass.
Cheat!
Objective-C's @defs(class_name) directive will be replaced with
the structure of any ObjC class as a struct statement. Create a
typedef using the @defs() directive, then cast your object pointer
to that type. You now have direct access all ivars; scope
restrictions are thrown out the window.
For obvious reasons, this isn't something you want to do on a
regular basis.
--
James Bucanek
Thats a brilliant way of doing it actually.
And yes its not something I'll be doing regularly.
- Keith
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40gmail.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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