On 22 Jan 2014, at 15:33, Remco Poelstra <[email protected]> wrote:
> I'm writing an app which has to import files without a fixed file extension. 
> There are about 10 different commonly used file extensions around.

 You can specify a whole list of file extensions in your Info.plist for each 
document class. That way they get an icon, can be double-clicked to open in 
your app etc.

> Is it possible to associate a file to my app based on the file contents? Much 
> like how file (1) determines a file's type?

 Nope.

> Or should I simply register all know file extensions?


 That's the preferred solution. How common is it that files have an extension 
that is not on your list, or even no extension at all? If it's just something 
some weird people do, then rest assured we all have to cope with those people. 
Just tell them to re-add your preferred extension. If it's a little more 
common, you can also take advantage of command-drag support: If you hold down 
the command key while dragging a file on an application icon, it will be opened 
in your application, regardless of its filename suffix (You may have to 
override application:openFile: in your app delegate to apply a default file 
type in this case, though).

So if this is a rare case, you can probably give this workaround to any users 
that have this problem. That's better than accepting any old file (e.g. by 
registering for creator code '****'), and having to cope with completely wrong 
files someone just tried dragging on your app icon.

-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."




_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to