I’m looking to cancel a previous request made with
my performSelector:"refreshSpotifyTrackBG" withObject:(missing value) afterDelay:aRefreshTime
from the Docs
+ (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:
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?
It’s a class method, so:
current application's NSObject's cancelPreviousPerformRequestsWithTarget:me
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?
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.