• 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: -[NSURL path] returning empty string for relative file URL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -[NSURL path] returning empty string for relative file URL


  • Subject: Re: -[NSURL path] returning empty string for relative file URL
  • From: Niko Matsakis <email@hidden>
  • Date: Fri, 11 Nov 2005 16:34:47 +0100


Well, I'm not creating the NSURL in this case, the NSTextView is. I'm shoving some XHTML into the NSTextView and it's interpreting anchors as clickable links. When clicked, my textView:clickedOnLink:atIndex: method gets called with the NSURL in question. The original XHTML had this:
<a href="foo.bar"><span>Link to foo.bar</span></a>
But if I shove it into the NSTextView like that, the NSURL I get back looks like this:
applewebdata://108AB768-64CD-41CF-94FA-C4558EBA0B1E/foo.bar
which is a bit difficult to deal with.



Ah, I see. Sorry, missed the full context of the original message. Just went and fished it out of the archives. I suspect that in your initial call to initWithData:options:documentAttributes:error: on the NSAttributedString, you want to provide the following entry in your options: dictionary. If you look in the documentation, you'll see an entry called NSBaseURLDocumentOption; I believe if you set that to the URL of the XHTML file, you should be all set. You can construct the URL using one of the NSURL convenience methods.


I also found this which may be relevant:

http://homepage2.nifty.com/hoshi-takanori/cocoa-browser/prog- tips.html suggests you want to do something like:

NSData *data = < HTML data >;
NSURL *url = < base URL >;
NSAttributedString *attrString = [[NSAttributedString alloc]
initWithHTML: data baseURL: url documentAttributes: (NSDictionary **) NULL];
[[textView textStorage] setAttributedString: attrString];
[attrString release];

in this case the parameter "baseURL" controls the URL that the relative link will be interpreted against. I believe this is the same except easier to read, but perhaps it won't work with XHTML, not sure.


If that doesn't help, I know nothing more! :)


Niko _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: -[NSURL path] returning empty string for relative file URL
      • From: Glen Simmons <email@hidden>
References: 
 >-[NSURL path] returning empty string for relative file URL (From: Glen Simmons <email@hidden>)
 >Re: -[NSURL path] returning empty string for relative file URL (From: Rob Mayoff <email@hidden>)
 >Re: -[NSURL path] returning empty string for relative file URL (From: Glen Simmons <email@hidden>)
 >Re: -[NSURL path] returning empty string for relative file URL (From: Niko Matsakis <email@hidden>)
 >Re: -[NSURL path] returning empty string for relative file URL (From: Glen Simmons <email@hidden>)
 >Re: -[NSURL path] returning empty string for relative file URL (From: Niko Matsakis <email@hidden>)
 >Re: -[NSURL path] returning empty string for relative file URL (From: Glen Simmons <email@hidden>)

  • Prev by Date: NSMenu's window commands are automagically greyed out...
  • Next by Date: Closing a sheet
  • Previous by thread: Re: -[NSURL path] returning empty string for relative file URL
  • Next by thread: Re: -[NSURL path] returning empty string for relative file URL
  • Index(es):
    • Date
    • Thread