Appkit Delegates - openFile vs openFiles

Hi,

Wanted to understand the difference between the delegate methods "openFile" and "openFiles" used to open files with an application in MacOS.

I've tried the following scenarios:

  1. Application Delegate with both openFile and openFiles methods present:

    • Opening single file - In this case "openFiles" gets triggered with the file path in the filenames parameter array. "openFile" does not get called.
    • Opening multiple files - In this case, again, "openFiles" gets triggered with the file paths of all the files in the filenames parameter array. "openFile" does not get called again.
  2. Application Delegate with only "openFile" delegate method present:

    • Opening single file - In this case "openFile" gets triggered with the file path in the filename parameter.
    • Opening multiple files - In this case "openFile" gets triggered multiple times with the file path in the "filename" parameter. The number of times it gets triggered depends on the number of files that were opened by the application and each time its triggered, it gets the path of the subsequent file.

My observation was that, if "openFiles" was present in the delegate along with "openFile", the latter never gets called. Is this observation correct?

Also, since "openFIle" delegate can still handle multiple file opens at the same time, albeit it is triggered multiple times, is it safe to just use "openFile" in the delegate file(ie. not use openFiles delegate at all)?

Replies

My understanding is that openFiles uses and array of files.

openFile does in fact call openFiles with a single item in the array.

openFile is a convenience to avoid having to type openFiles([aFile]) but just write openFile(aFile).

Both will give the same result.