• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: openURL and Bookmarked location
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: openURL and Bookmarked location


  • Subject: Re: openURL and Bookmarked location
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Mon, 26 Jul 2004 23:24:27 -0700

Hello...

The short answer:

Use the LSOpenCFURLRef() function provided by LaunchServices. It is what NSWorkspace normally uses to open URLs.

NSURL *yourURL = [NSURL URLWithString:@"file:///someFolder/features.html#wp1057682"];
LSOpenCFURLRef( (CFURLRef)yourURL, NULL);

Note that this only fixes the issue from the perspective of sending the request to open the url, and it is still possible that the application opening the url will not do it properly, although one would hope that any web browser would handle opening file urls properly.


The long answer:

As far as AppKit is concerned, a file url is not a real url, and is just something that can be turned into a path.

In most of the methods in the AppKit framework where there is a ...File: variant that takes an NSString *path and a ...URL: variant which takes a NSURL *url, the version that takes a NSURL is hardcoded to check for file scheme urls and convert them to a path and call the corresponding ...File: variant.

In this particular case, the NSWorkspace instance method openURL: is converting your url to a path and calling openFile: instead. Any other information included in the URL is lost when it is converted to a path.

You can also run into problems because of the application opening the url (in particular with any app that is NSDocument based), since nearly every method in NSDocumentController and NSDocument involved in the process of opening the contents of a url is also hardcoded to convert a file scheme url to a path. This means that any NSDocument based application that wants to accept file urls without having them converted to a path must completely override and reimplement the mechanism for opening urls, instead of being able to simply override readFromURL:ofType: in a NSDocument subclass.


Please file a bug at bugreporter.apple.com regarding NSWorkspace's implementation of the openURL: method. Make sure you include the reason why the current behavior is a problem (basically the same information as you provided in your email to the list) so that eventually they will understand that a file url != a path.


Hope that helps,

Louis

...

openURL no doubt open the correct HTML file in the
default Application/Browser but does not scroll to the
bookmarked location.

The browser URL shows the URL as

file:///Applications/MyFolder/sub folder/EN/docs_htm/features.html
when it should be

file:///Applications/MyFolder/sub folder/EN/docs_htm/features.html#wp1057682

I have logged the incoming URL, everthing is fine but
i don't know what openURL does,it opens the URL
without the bookmark.

Any help on this is greatly appreciated.

Thanks in advance.

Rgds
Manish
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >openURL and Bookmarked location (From: Manish Pattath <email@hidden>)

  • Prev by Date: Re: non-root app writing to root file
  • Next by Date: Re: Drawing strings at 20fps
  • Previous by thread: openURL and Bookmarked location
  • Next by thread: NSTimer firing issue
  • Index(es):
    • Date
    • Thread