Re: Outlet from Different Implementation?
Re: Outlet from Different Implementation?
- Subject: Re: Outlet from Different Implementation?
- From: Graham Cox <email@hidden>
- Date: Tue, 16 Sep 2008 15:12:47 +1000
On 16 Sep 2008, at 12:19 pm, Jeshua Lacock wrote:
Is it possible to get the value of an outlet from a different
@implementation?
For instance, if I have the two following interfaces and the outlets
have been connected in IB:
@interface MyGLView : NSOpenGLView
{
NSTimer *pTimer;
}
@end
@interface MyContent : NSView
{
IBOutlet id MyOutlet;
}
@end
I am trying to get the value of the MyOutlet outlet (from MyContent
implementation) from a function in the MyGLView implementation.
I thought something like this would work (but doesn't):
float foo = [[MyContent MyOutlet] floatValue];
Any information would be greatly appreciated.
You need to write an accessor method to return it, as written above
what you're doing isn't supported automagically. You could access it
as a named property:
float foo = [[MyContent valueForKey:@"MyOutlet"] floatValue];
but when you consider what valueForKey: has to do to make this work,
if performance is a consideration you'll be much better off writing an
accessor. Since they are your classes, there's no reason why you
couldn't or shouldn't.
hth,
Graham
_______________________________________________
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