Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tcga

macrumors newbie
Original poster
Aug 19, 2020
2
0
Hello,

I am trying to build my first Xcode app (just a little helper app for myself).

The following code gives me this error: "[AppDelegate applicationWillFinishLaunching:]: Can’t get name of every file of «class ects» of class "NSObject". (error -1728)"

AppleScript:
on applicationWillFinishLaunching_(aNotification)
        -- Insert code here to initialize your application before any files are opened

        tell application "Finder"
            set file_list to name of every file of entire contents of alias "macOS2:Users:user:DEVONthink:"
        end tell

end applicationWillFinishLaunching_

As far as I can see this is the offending code block from the larger code (as everything else seemed to work), but for completeness I posted the rest of the code below. In ScriptDebugger that code works without any errors.

AppleScript:
script AppDelegate
    property parent : class "NSObject"
    property sizeWindowPrimary : missing value
    property sizeWindowInbox : missing value
    property sizeDesktop : missing value
    property databaseFolderPath : "/Users/user/DEVONthink/"
    property databaseNames : missing value
    property file_list : missing value
    
    -- IBOutlets
    property theWindow : missing value

    
    on applicationWillFinishLaunching_(aNotification)
        -- Insert code here to initialize your application before any files are opened
        
        --SETUP FOR WINDOW SIZES:
        set sizeWindowInbox to {0, 23, 640, 0} --replace 23 with 116 once the DEVONthink Helper is active and floats above
        set sizeWindowPrimary to {641, 23, 0, 0} --replace 23 with 116 once the DEVONthink Helper is active and floats above

        set sizeDesktop to {}

        tell application "Finder"
            set sizeDesktop to get the bounds of the window of the desktop
        end tell

        set item 4 of sizeWindowInbox to item 4 of sizeDesktop
        set item 3 of sizeWindowPrimary to item 3 of sizeDesktop
        set item 4 of sizeWindowPrimary to item 4 of sizeDesktop


        --SET UP FOR DATABASE PATH AND DATABASE NAMES

        tell application "Finder"
            set file_list to name of every file of entire contents of alias "macOS2:Users:user:DEVONthink:"
        end tell


     end applicationWillFinishLaunching_

And everything above the line "--SETUP FOR DATABASE PATH AND DATABASE NAMES" works when I comment out the offending part.


I'd really appreciate any pointers.

Thanks a lot!
 

Red Menace

macrumors 6502a
May 29, 2011
584
231
Colorado, USA
It isn't liking that usage of alias for whatever reason. Changing the file reference to:

Code:
folder "macOS2:Users:user:DEVONthink:"
-- or --
Code:
("macOS2:Users:user:DEVONthink:" as alias)
works for me.

Note that you need to have the Privacy - AppleEvents Sending Usage Description (NSAppleEventsUsageDescription) key in the Info.plist to get permission for Apple Events (the default template doesn't include that).
 
  • Like
Reactions: tcga
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.