I am coding Mac App on Xcode with Applescript.
I made a function that doesn't stop forever, but I can't stop it.
It starts when I push a button that is located on the window.
Because this function doesn't stop, the button appears pushed forever.
And I have to force quit with 'Command+Option+Escape'. (Even if you do this activity, this app may not be stop.)
I want release the button before the function starts, and I want to stop this function safely with pushing another button.
This is my example. To stop this, push the "Stop" button on Xcode.
property parent : class "NSObject" property mylabel : missing value on applicationWillFinishLaunching_(aNotification) -- Insert code here to initialize your application before any files are opened end applicationWillFinishLaunching_ on myStartButtonHandler_(sender) my myForeverFunction() end myStartButtonHandler_ on myStopButtonHandler_(sender) --How can I stop "myForeverFunction"? end myStopButtonHandler_ on myForeverFunction() set a to 0 repeat 100 times set a to a+1 mylabel's setStringValue_(a) delay 1 end repeat end myForeverFunction on applicationShouldTerminate_(sender) -- Insert code here to do any housekeeping before your application quits return current application's NSTerminateNow end applicationShouldTerminate_ This is the project file --> https://dl.dropboxusercontent.com/u/97497395/test.zip
Sorry I am Japanese, I can't write English very well.