• 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: Call method from a different file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Call method from a different file


  • Subject: Re: Call method from a different file
  • From: "I. Savant" <email@hidden>
  • Date: Wed, 30 Aug 2006 16:52:32 -0400


Brian, I recommend getting a good book on Objective-C as this is fairly basic stuff you should get a good handle on before pressing on. Specifically, don't think of things in terms of "files". Think in terms of "classes" and "instances of a class". Your .m file contains the description of the implementation of your class and the little blue box in your nib that represents your AppController class is an instance of that class.


You *could* create an outlet on your NSTableView subclass called "controller" or "keyHandler" or "bob" if you like. Update your nib per the easily-found instructions (I usually drag the header file into the nib to update it). The outlet should now appear and you should now be able to ctl-drag a connection from your custom table view to the app controller instance in the nib. Now you have a channel through which to contact the app controller:

[bob tableKeyDown:myKeyDownEvent];

Since "bob" points to your app controller, you can add the method "tableKeyDown:" or whatever you like to the AppController class and handle the key event any way you wish.

Of course this may not be the best way of doing things for your particular situation, but it's "a" way.

--
I.S.


On Aug 30, 2006, at 4:33 PM, Brian Amerige wrote:

Hi all,

I've got a subclassed NSTableView, and I'm overriding the keyDown method. However, the method I want to call (when, for example, the enter key is pressed) is in a different file. (My AppController.m file). How would I call it from my subclass?

Thanks.
Brian Amerige
http://extendmac.com
http://cocoaforum.com


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Call method from a different file (From: Brian Amerige <email@hidden>)

  • Prev by Date: Menu item loses selectedRow?
  • Next by Date: Re: Removing/Adding views in drawRect:
  • Previous by thread: Call method from a different file
  • Next by thread: Re: Call method from a different file
  • Index(es):
    • Date
    • Thread