• 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 a handler from another script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling a handler from another script


  • Subject: Re: Calling a handler from another script
  • From: Stan Cleveland <email@hidden>
  • Date: Tue, 23 Jun 2015 17:04:55 -0700

On Jun 23, 2015, at 4:43 PM, Shane Stanley <email@hidden> wrote:

<snip>
There are a couple of things. First, you can't make a subclass of an AS-based class. It doesn't generate an error, but there's no inheritance -- your second class ends up just another subclass of NSObject.

 But the clue is in the error message:

 Ctrlr[4168:303] *** +[CtrlrAppDelegate buttonSetImage:]: unrecognized function setImage_. (error -10000)

See the + sign? That means you are addressing the CtrlrAppDelegate *class*, calling a class method. And that's what your code shows, too. But in a class, properties are meaningless, so myButton will have no value -- hence the problem with setImage_. You want to address your *instance* of CtrlrAppDelegate. So you need a property that refers to the CtrlrAppDelegate instance…
<snip>

Hi Shane,

Since my original post, I did some web searching and found a MacScripter post by you from 2009. To quote it:

The problem is that your code is trying to do things to the class, when what you want to do is call handlers and change properties in a particular instance of the class, the one in the .xib file. So rather than addressing 'current application's class "AppController"', you need to make a new property, connect it to the instance of AppController in IB, and then target that property.

If I understand correctly, your post from 2009 and your post from today say the same thing. So I did add a property to each script and bind it to the appropriate NSObject of the other script in the XIB. Addressing a script via the property does access it as an instance and allows calling the method.

I owe you double thanks! Once for today and another for the historical you from 2009. Thanks too for the helpful insights into parsing error messages.

Stan C.

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

This email sent to email@hidden

  • Follow-Ups:
    • Re: Calling a handler from another script
      • From: Shane Stanley <email@hidden>
References: 
 >Calling a handler from another script (From: Stan Cleveland <email@hidden>)

  • Prev by Date: Re: Calling a handler from another script
  • Next by Date: Re: Calling a handler from another script
  • Previous by thread: Re: Calling a handler from another script
  • Next by thread: Re: Calling a handler from another script
  • Index(es):
    • Date
    • Thread