• 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: "a.d. jensen" <email@hidden>
  • Date: Tue, 19 Sep 2006 19:12:58 -0500

On Sep 19, 2006, at 6:19 PM, Rush Manbert wrote:

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.

Nope, doesn't seem to make a difference. I removed the TextField and replaced it with a TextView, reconnected up my instantiated class, same results. This:



if ([[dataSource representation] canProvideDocumentSource])
{
myString = [NSString stringWithString:[[dataSource representation] documentSource]];
//myString = [NSString stringWithCString:"Oh, for freaking sake" encoding:NSASCIIStringEncoding];
}
else
{
myString = [NSString stringWithCString:"Cannot get text representation" encoding:NSASCIIStringEncoding];
}
[sourceEdit setString: myString];


results in an empty text area. Removing the comment from the "Oh, for freaking sake" line results in that text appearing. If I drop into the debugger on the "setString" line, I can see that myString is valid and contains the source of the page (until it truncates.)


dale

--
email@hidden   http://kandsmil.blogspot.com

Only a fool turns away from an angel,
Vision in white steps through the door,
Holds out her hand, I say 'No I'm not ready'
I open my eyes and let the dream fade away.
  -- echolyn, "on any given nite"


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

  • Prev by Date: Re: Deletes Objects On Remove
  • Next by Date: Re: Fast double click, vs slow one, different actions?
  • Previous by thread: Re: Displaying HTML in an NSTextField
  • Next by thread: Custom attrs preserved in RTF files?
  • Index(es):
    • Date
    • Thread