accessing ivars in - (id)init
accessing ivars in - (id)init
- Subject: accessing ivars in - (id)init
- From: Ron Fleckner <email@hidden>
- Date: Sat, 10 Jan 2009 15:07:20 +1100
Hi,
I read with interest the guidance in a recent thread regarding
accessing ivars in -init methods. In a subclass of NSWindow I call
[self setBackgroundColor:someColor] even though I don't override that
method. This has worked in the wild for about two years, but I wanted
to conform to best practice. I tried accessing backgroundColor
directly, but the compiler won't let me because that ivar doesn't
exist in my subclass. Calling the method on super works, but when I
quit my app the debugger started (but failed to load the program after
about a minute!).
How should I set the background colour in this situation? Should I
override -backgroundColor and -setBackgroundColor: or should I just
keep using [self setBackgroundColor:aColor] in my -init?
For your information, -backgroundColor and -setBackgroundColor: are
declared in NSWindow.h
Confused.
Ron
_______________________________________________
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