• 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: Displaying HTML in an NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying HTML in an NSTextField


  • Subject: Re: Displaying HTML in an NSTextField
  • From: Rush Manbert <email@hidden>
  • Date: Tue, 19 Sep 2006 16:19:50 -0700

a.d. jensen wrote:
In an attempt to do some debugging, I'd like to see the source code of a webview. So, I've implemented this code:

---

WebDataSource *dataSource = [[webView mainFrame] dataSource];
NSString *myString;
if ([[dataSource representation] canProvideDocumentSource])
{
myString = [NSString stringWithString:[[dataSource representation] documentSource]];
}
else
{
myString = [NSString stringWithCString:"Cannot get text representation" encoding:NSASCIIStringEncoding];
}
[sourceEdit setStringValue: myString];


---

When the page loads, nothing shows up in the text field (though, if there's something in there already, it's erased.) If I drop into the debugger, I can see the source in "myString" (though truncated, which is why I'm trying to put it in a scrolling text field in the first place) and if I change the line that assigns into myString to be a "stringWithCString", the text field is updated properly.

So, my guess is that the NSTextField is interpreting the web page source code and just not displaying it properly (or rendering it, or something). Any ideas on what to do to make it display properly (or tell me how wrong my guess is :-)

When I do this I use a NSTextView, and set its content with setString, so my last line would be:

[textView setString:myString];

I don't know why you're having problems setting the contents of the NSTextField, but you might try this instead.

- Rush
_______________________________________________
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: Displaying HTML in an NSTextField
      • From: "a.d. jensen" <email@hidden>
References: 
 >Displaying HTML in an NSTextField (From: "a.d. jensen" <email@hidden>)

  • Prev by Date: Re: Custom attrs preserved in RTF files?
  • Next by Date: Re: Deletes Objects On Remove
  • Previous by thread: Re: Displaying HTML in an NSTextField
  • Next by thread: Re: Displaying HTML in an NSTextField
  • Index(es):
    • Date
    • Thread