How to use NSAutoreleasePool in AppleScriptObjC

前端 未结 1 677
梦毁少年i
梦毁少年i 2021-01-24 19:19

I am wondering how to stop another function from a background function.
In addition, I have to drain NSAutoreleasePool, but I don\'t know how to do it.
I think this app

相关标签:
1条回答
  • 2021-01-24 19:40

    An easy way to stop the function is to have a variable. Check the value of the variable. If the variable is true for example then you can exit your repeat loop and drain the autorelease pool. I'm running to work now so no time to write code. Good luck.

    EDIT: If you use an NSTimer to fire your handler, as opposed to a repeat loop, then you can invalidate the timer to stop it from running the handler. I use this to invalidate a timer because you should always check that the timer is valid before invalidating it... it will crash if you invalidate a non-valid timer.

    -(void)deleteMyTimer {
        if ([myTimer isValid]) {
            [myTimer invalidate]
            myTimer = nil;
        }
    }
    
    0 讨论(0)
提交回复
热议问题