• 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: Calling IB Actions In PB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling IB Actions In PB


  • Subject: Re: Calling IB Actions In PB
  • From: j o a r <email@hidden>
  • Date: Sun, 14 Apr 2002 16:01:21 +0200
  • Resent-date: Sun, 14 Apr 2002 16:28:18 +0200
  • Resent-from: j o a r <email@hidden>
  • Resent-message-id: <email@hidden>
  • Resent-to: email@hidden

On Sunday, April 14, 2002, at 03:44 , Albert Atkinson wrote:

[toolbarItem setTarget: self];
[toolbarItem setAction: @selector(openDocument:)];
<snip>
[toolbarItem setTarget: self];
[toolbarItem setAction: @selector(newDocument:)];

You should ask yourself, "what object is responding to these action methods". In this case it looks to be a document controller, perhaps even the shared / default dito? If so, try something like this:

[toolbarItem setTarget:[NSDocumentController sharedDocumentController]];

The reason that you didn't know this is because normally these actions are sent from a menu item, and the glue to the object is handeled by a piece of Cocoa magic know as "first responder". This is not something that is easy to grok at first - but it's not a very difficult concept, and definitively one of the things that make Cocoa great, so you should learn it sooner rather then later... :)
Read the documentation for NSResponder and the "first responder chain", and the overview / topic documentation for event handling - that is linked from the documentation of NSResponder.

Good luck,

j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Loop through NSTableView to set NSCell state
  • Next by Date: Re: Calling IB Actions In PB
  • Previous by thread: Re: Calling IB Actions In PB
  • Next by thread: Re: Calling IB Actions In PB
  • Index(es):
    • Date
    • Thread