I want to make an autoreleasepool in AppleScriptObjc with ARC, but I couldn't retain it. Here's the code:
property NSAutoreleasePool : class "NSAutoreleasePool"
script AppDelegate
...
on buttonClicked_(sender)
set pool to NSAutoreleasePool's alloc()'s init()
...
pool's drain()
end buttonClicked_
end script
In the code, I got this debug error:
-[NSAutoreleasePool retain]: Cannot retain an autorelease pool (error -10000)
I googled and I found that "[[NSAutoreleasepool alloc] init]" can be used only without ARC, instead, "@autoreleasepool" can be used with ARC and without ARC.
In Objective-C, we can use @autoreleasepool. Example:
int main()
{
@autoreleasepool {
...
}
}
But AppleScriptObjc doesn't have '{' or '}', so we can't use @autoreleasepool. However, I tried it, and I got an error.
Code:
@autoreleasepool
...
Error:
error: Expected βendβ but found unknown token. (-2741)
How can I use @autoreleasepool in AppleScriptObjc?