Search code examples
objective-cxcodecocoaxcode7.3

In a Cocoa Mac Os X Desktop Application, can I configure the project so that files with no extensions can be dragged into the app's icon?


In a Cocoa Mac Os X Desktop Application, can I configure the project so that files with no extensions can be dragged into the app's icon ? Thanks


Solution

  • Your app identifies which files it handles (which controls what types can be dragged onto it, and for which your app appears in the Open With menu in Finder) via Uniform Type Identifiers.

    In Xcode, you set this in "Document Types" in the "Info" tab for your app target. The root type (i.e., the type you want for all files) is public.data. Basically just add a Document Type, set the identifier to public.data, and you're good.

    Visual aid:

    Xcode screenshot showing document type for all files

    Note that this won't cover folders. For that, use public.folder.