Currently I review some older projects to get them running on 64-bit.
Now I have a strange error and no idea what's wrong.
I call AppleScript (Xojo 2019r1.1 on macOS 10.14.15) via declares (as shown in Proper way to execute an AppleScript? .
It worked fine in past but now I get a strange error.
In a push button's action event paste following code
Soft Declare Function NSClassFromString Lib "Cocoa" (classname As CFStringRef) As ptr Soft Declare Function initWithSource Lib "Cocoa" selector "initWithSource:" (obj As ptr,source As CFStringRef) As ptr Soft Declare Function executeAndReturnError Lib "Cocoa" selector "executeAndReturnError:" (obj As ptr,ByRef error As ptr) As ptr Dim theScript As String = "tell application ""Finder"" to close window ""test""" Dim ASClass As Ptr = NSClassFromString("NSAppleScript") Dim scr As ptr Try scr = initWithSource(ASClass,theScript) Catch e As RuntimeException System.Log System.LogLevelError, "Got an Exception " + Str(e.ErrorNumber) System.Log System.LogLevelError, e.Message Return End Dim err As ptr Dim descriptor As ptr = executeAndReturnError(scr, err) If descriptor = Nil Then Dim e As RuntimeException e.Message = "Can't execute AppleScript!" End If
Now open a Window "test" in Finder and run the application. The window should be closed.
I get an exception
+[NSAppleScript initWithSource:]: unrecognized selector sent to class 0xa8539240
I have no idea what's wrong here because it worked well in past.