• 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
NSAttributedString and HTML
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSAttributedString and HTML


  • Subject: NSAttributedString and HTML
  • From: Chris Hanson <email@hidden>
  • Date: Sat, 21 Sep 2002 00:11:34 -0500

There's got to be something I'm just missing here.

I'm trying to create an attributed string with the HTML that I have in another string. I'm doing this from within an NSText delegate method, -[MyDocument textDidChange:]. I'm using Mac OS X 10.2.1 with the latest everything.

Here's my code:

- (NSAttributedString *)attributedStringForHTML:(NSString *)rawString
{
NSData *rawStringData;
NSAttributedString *htmlString;

rawStringData = [rawString dataUsingEncoding:NSUTF8StringEncoding];

htmlString = [[[NSAttributedString alloc] initWithHTML:rawStringData
documentAttributes:NULL] autorelease];

return htmlString;
}

What's strange is that as soon as it hits -[NSAttributedString initWithHTML:documentAttributes:], it throws an exception:

Exception raised during posting of notification. Ignored.
exception: *** +[MyDocument attributedStringWithHTML:documentAttributes:]:
selector not recognized

Of course it's not recognized! I don't want to write my own HTML parser, that's what the AppKit additions to NSAttributedString are for! And how the heck is it getting at MyDocument?

What's odd is that using NSAttributedString like this to work fine for projects like Cocoa Browser. And it certainly doesn't have an implementation of +[MyDocument attributedStringWithHTML:documentAttributes:]. What's going on?

-- Chris

--
Chris Hanson | Email: email@hidden
bDistributed.com, Inc. | Phone: +1-847-372-3955
Making Business Distributed | Fax: +1-847-589-3738
http://bdistributed.com/ | Personal Email: email@hidden
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSAttributedString and HTML
      • From: Finlay Dobbie <email@hidden>
    • Re: NSAttributedString and HTML
      • From: Ali Ozer <email@hidden>
    • Re: NSAttributedString and HTML
      • From: Richard Van Deren <email@hidden>
    • Re: NSAttributedString and HTML
      • From: Jonathan Jackel <email@hidden>
  • Prev by Date: NSKeyedUnarchiver Exception problem
  • Next by Date: Re: Bad access when application quits - NSApp terminate
  • Previous by thread: NSKeyedUnarchiver Exception problem
  • Next by thread: Re: NSAttributedString and HTML
  • Index(es):
    • Date
    • Thread