• 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: Use objects calling an Outlet but not an Action
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Use objects calling an Outlet but not an Action


  • Subject: RE: Use objects calling an Outlet but not an Action
  • From: "Jonathan E. Jackel" <email@hidden>
  • Date: Tue, 2 Dec 2003 10:17:43 -0500

> How can I do an object action without call a Target/Action into
> Interface Builder, or without call an Outlet?
>

Do you mean, how do you invoke an action from code? You just send the
message to the object:

[yourObject yourAction:nil];

The only caveat is that the argument to an action is always (id)sender.
Normally this is the UI element that the user clicked on. If the method
needs to know something about the sender, passing nil may not work. You may
be able to pass self or another object as the argument.

> example: When the application starts, a NSComboBox could be loaded with
> all the files and Directories of Root directory, without any button
> pressed or something like this (without any action called).

This example suggests another option: have your IBAction method call another
method which does the real work. When you need to do the work (load the
directories, for instance) in your code, you call the worker method. When
you need to do the work from the UI, the button (or whatever) invokes the
action, which in turn invokes the worker method.

Jonathan
_______________________________________________
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.

References: 
 >Use objects calling an Outlet but not an Action (From: Roberto <email@hidden>)

  • Prev by Date: Re: NSBezierPath
  • Next by Date: adress book modification
  • Previous by thread: Use objects calling an Outlet but not an Action
  • Next by thread: Re: Use objects calling an Outlet but not an Action
  • Index(es):
    • Date
    • Thread