Anders Sewerin Johansen
Anders Sewerin Johansen

Reputation: 1656

How do I know what type of document handleOpenURL is responding to?

Let's say I have registered several schemes as appropriate for my app, such as text file and PDF.

I open an attached file in the mail app. My app is invoked, and the handleOpenURL method is fired with an URL.

Do I have to (crudely) parse the URL, or.. what?

Upvotes: 0

Views: 231

Answers (2)

Martin R
Martin R

Reputation: 539685

You can call the NSURL method getResourceValue:forKey:error: with the NSURLTypeIdentifierKey to get the uniform type identifier (UTI) of the file passed to the application.

Upvotes: 1

Michael Dautermann
Michael Dautermann

Reputation: 89509

It isn't that hard to get at important bits of the URL (via NSURL's pathExtension, for example, you might know what kind of .doc or .pdf or .txt file you're trying to open)

Upvotes: 1

Related Questions