Since my attempts haven't been fruitful so far, I decided to explore Launch Services, which the Finder uses to do these things. To do that, I need to make a file that I know I can load into my application. In this post, I show two ways to accomplish this very simple first step: one way is with an NString that is a path to the file, and one using NSURL. As the docs say: "NSURL objects can be used to refer to files, and are the preferred way to do so."
To make things simple, I am building and running from Terminal. The file is a text file containing "my data", with the .txt extension. Since its straight text, we can use either encoding as shown in the listing:
encoding:NSASCIIStringEncoding
encoding:NSUTF8StringEncoding
If you want garbage collection, see here.
As step 2 in the exploration, I changed the extension to be testuff. (Do this in the information window, otherwise the Finder will sometimes just hide the extension). My test application will still open the file correctly, if the extension is changed in the path.
If I now set "Open with:" to TextEdit or Smultron, it works properly. So the question is: what do these applications need to implement in order to respond properly to the double-click? What message does Launch Services send them?
The output from step 1 as displayed by NSLog (logging info removed):
And the code listing: