0

I'm getting troubles getting the applications associated with a remote file how has a URL like: "http://servername/folder/file.png".

The code I use is:

...
NSURL *url = [NSURL fileURLWithPath:@"http://servername/folder/file.png"];
NSArray *apps = (NSArray *)LSCopyApplicationURLsForURL((CFURLRef) url,kLSRolesAll);
...

I also try using URLWithString: but the result is the same. What is the correct approach for this?

Edit after Joshua replay:

Sorry for may bad redaction. The problem is that the LSCopyApplicationURLsForURL call return nil.

Bruno Berisso
  • 1,091
  • 11
  • 33

1 Answers1

0

First, -fileURLWithPath: expects a file system path like @"/Users/me/Desktop/MyFile.png".

Second, you don't say what the "same" results are and what is wrong with them, so it's difficult to tell you what the problem is.

The docs say this:

If the item URL’s scheme is file (designating either a file or a directory), the selection of suitable applications is based on the designated item’s filename extension, file type, and creator signature, along with the role specified by the inRolesMask parameter; otherwise, it is based on the URL scheme (such as http, ftp, or mailto).

So what are you getting and what do you expect to get?

Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135