Re: me and my do not refer to your script's class
Re: me and my do not refer to your script's class
- Subject: Re: me and my do not refer to your script's class
- From: Dave <email@hidden>
- Date: Tue, 28 Dec 2010 00:49:46 -0600
On Dec 26, 2010, at 12:22 AM, Shane Stanley wrote:
> On 26/12/10 1:57 PM, "Dave" <email@hidden> wrote:
>
>> The following causes nothing to happen, not even a log message. It's as though
>> Applescript is treating it as a call to a run handler (which would explain the
>> silence) instead of an Objective-C method invoke.
>>
>>> performSelector_withObject_afterDelay_("ReProbe:", missing value, 5)
>
> It works fine here -- I wonder if the problem is in the handler you're
> calling. This is what I'm using:
>
> on ReProbe_(whatever)
> log "ReProbe:"
> end ReProbe_
Nope, I can't get it to run either as a class method or instance method. And no syslog messages appear. I've also tried other variants such as passing "missing value" for the parameter and invoking the performSelector in a handler in the same script that was triggered by an NSTimer event. (The timer event handler runs but, again, the performSelector does nothing.)
I've bypassed the problem by doing the same performSelector in an Obj-C file. Works fine from there.
Here's the failing script code:
---- Instance Method:
script Test2AppDelegate
on applicationWillFinishLaunching_(aNotification)
set numberArg to current application's NSNumber's numberWithInt_(0)
performSelector_withObject_afterDelay_("iCalProbeAttempt:", numberArg, 30)
...
on iCalProbeAttempt_(theObj)
log "iCalProbeAttempt_()"
...
----- Class Method:
property myDelegate : class "Test2AppDelegate"
script Test2AppDelegate
property parent : class "NSObject"
on applicationWillFinishLaunching_(aNotification)
set numberArg to current application's NSNumber's numberWithInt_(0)
myDelegate's performSelector_withObject_afterDelay_("iCalProbeAttempt:", numberArg, 30)
...
on iCalProbeAttempt_(theObj)
log "iCalProbeAttempt_()"
...
>> The following lines all print out: <Test2AppDelegate @0x2005fabe0: OSAID(5)>
>>
>> on applicationWillFinishLaunching_(aNotification)
>>
>> log me
>> log |description|()
>> log me's |description|()
>>
>> But the following lines print: Test2AppDelegate
>>
>> on applicationWillFinishLaunching_(aNotification)
>>
>> log current application's class "Test2AppDelegate"
>> log current application's class "Test2AppDelegate"'s |description|()
>>
>> And "me" tests not equal to the longer expression, so these can't be the same
>> objects.
>
> They aren't the same: the first is the app delegate object, which is an
> instance of the class, while the second is the class itself. Generally, you
> want to call methods on an instance of a class rather than the class itself.
Yes, I see that now. Thanks. _______________________________________________
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