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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to