• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Outlet from Different Implementation?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Outlet from Different Implementation?
      • From: Jeshua Lacock <email@hidden>
References: 
 >Outlet from Different Implementation? (From: Jeshua Lacock <email@hidden>)

  • Prev by Date: Outlet from Different Implementation?
  • Next by Date: Re: NSWindowController
  • Previous by thread: Outlet from Different Implementation?
  • Next by thread: Re: Outlet from Different Implementation?
  • Index(es):
    • Date
    • Thread