• 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
HTML format Text Fields?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

HTML format Text Fields?


  • Subject: HTML format Text Fields?
  • From: Richard Adams <email@hidden>
  • Date: Thu, 30 Aug 2001 19:26:19 -0700 (PDT)

I noticed that HTML formatted text is showing up what
look like maybe NSTextFelds - for example I created a
file, sample.html, in emacs, double clicked it in the
Finder and it opened up in TextEdit. It was displayed
as nicely formatted HTML.

So, I got to thinking that I'd like to have have HTML
formatted text in my app too. I dug around a bit and
noticed the initWithHTML method in NSAttributedString.
This sorta works. I tried the code below (this is a
method called in response to clicking a button next to
a NSTextField called myTextField):


- (IBAction)Button4:(id)sender
{
NSAttributedString *attributedString;
NSData *someData;
NSURL *theURL;
theURL = [NSURL URLWithString:
@"http://www.google.com/index.html";];
someData = [NSData dataWithContentsOfURL: theURL];
attributedString = [NSAttributedString alloc];
attributedString = [attributedString initWithHTML:
someData documentAttributes: nil];
[myTextField setAttributedStringValue:
attributedString];
}

This *almost* works. I get something sometimes. If I
click int he NSTExtField, I get the plain text from
the page.

Does anyone know anything about this method and making
it work?

Alternately, any better ideas for displaying simple
HTML output?

** Rich ***
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com


  • Follow-Ups:
    • Re: HTML format Text Fields?
      • From: Finlay Dobbie <email@hidden>
  • Prev by Date: [NSScreen resetScreens];
  • Next by Date: Re: [NSScreen resetScreens];
  • Previous by thread: Re: [NSScreen resetScreens];
  • Next by thread: Re: HTML format Text Fields?
  • Index(es):
    • Date
    • Thread