Thursday, February 25, 2021

#1 2020-12-10 10:49:44 pm

technomorph
Member
Registered: 2017-12-14
Posts: 178

Canceling Previous Request

I'm looking to cancel a previous request made with

Applescript:

my performSelector:"refreshSpotifyTrackBG" withObject:(missing value) afterDelay:aRefreshTime

from the Docs

Applescript:

+ (void)cancelPreviousPerformRequestsWithTarget:(id)aTarget;

Parameters

aTarget   
The target for requests previously registered with the performSelector:withObject:afterDelay: instance method.

I'm trying to figure out what the variable aTarget should be?

I've tried:

Applescript:

my cancelPreviousPerformRequestsWithTarget:me

*** -[AppDelegate cancelPreviousPerformRequestsWithTarget:]: unrecognized selector sent to object <AppDelegate @0x608000223920: OSAID(26) ComponentInstance(0x810000)>

do I need to create NSApplication sharedApplication() instance and send the cancel command to that?

Offline

 

#2 2020-12-10 10:56:20 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6565

Re: Canceling Previous Request

It's a class method, so:

Applescript:

current application's NSObject's cancelPreviousPerformRequestsWithTarget:me


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2020-12-10 11:03:15 pm

technomorph
Member
Registered: 2017-12-14
Posts: 178

Re: Canceling Previous Request

thanks I came across that in LNSW forum and just tried it.

Thanks I need to remember about the class method.  I saw the (+)
but figured that my instance AppDelegate would have access to the class methods as well?
But I guess not......

Eureka no wonder i've had trouble when I've created Class Methods and tried to call them
from my instance methods before.

quck question you might be able to answer:

can I declare a
(+)someFunction:someVariable
and also an instance function with sameName?
(-)someFunction:someVariable

Or is there a technique to calling your class methods from an instance of that class
without using the class name?

Offline

 

#4 2020-12-10 11:07:46 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6565

Re: Canceling Previous Request

Yes, you can have identical methods, as long as they have the same return and parameter types. (isMainThread is an example off the top of my head.) But it's potentially problematic in ASObjC classes, because they can't distinguish them.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)