Discussion:
NSURL troubles: Apple docset URLs with multiple fragment identifiers
Gerd Knops
2012-02-29 18:42:46 UTC
Permalink
Hi Everyone,

I am having a hard time converting URL strings pointing into Apple's docsets into actual URLs. Here is an example, which works fine when copying and pasting into Safari:

file:///Library/Developer/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/index.html#documentation/Cocoa/Reference/NSTokenFieldDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSTokenFieldDelegate/tokenField:shouldAddObjects:atIndex:

However a simple [NSURL URLWithString:urlString] returns nil when presented with the above URL. After adding percent escapes (which converts the '#' fragment identifiers into '%23') the URL can be created, but it does no longer work (eg when using NSWorkspace's openURL: method).

Looking closer at the URL there is something peculiar: It has two fragment identifiers. Safari simply appears to be ignoring the 'index.html#' bit, and ends up with that Reference.html file, which it opens and then jumps to the location indicated by the second fragment.

Any way to make this into a valid URL?

Thanks

Gerd

Loading...