Re: use of NSUnarchiver
Re: use of NSUnarchiver
- Subject: Re: use of NSUnarchiver
- From: Darin Duphorne <email@hidden>
- Date: Tue, 29 Jan 2002 21:51:24 -0600
Thanks. I see why it wasn't working now, although your code doesn't work
either (see debug below). Also, I am not trying to end up with an attributed
string in htmlView. Ultimately, I want to end up with the plain-text of the
html rendered as an attributed string. I understand that there is no cocoa
method for converting attributed strings to html (which surprises me since
I think WebObjects has such methods). As a first step, I will be satisfied
with the htmlView displaying the plain-text rtf underlying the attributed
string. Then, I can apply some available ANSI c methods for converting rtf
to html (at least until some methods are added to cocoa for this purpose). Any
suggestions would be appreciated.
2002-01-29 21:42:53.994 newtest[6751] -setLastTextContainer: called for an
attachment which already has a text container
2002-01-29 21:42:54.008 newtest[6751] Exception raised during background
layout: -setLastTextContainer: called for an attachment which already has
a text container
2002-01-29 21:42:54.026 newtest[6751] -setLastTextContainer: called for an
attachment which already has a text container
One thing strange I noticed when trying some trial and error methods --- a
debug message referenced an object "HTMLTable." Since I didn't create any
such object, I am assuming that some undocumented methods for manipulating
html may exist. Any thoughts on this one?
Thanks again,
Darin
On Tuesday, January 29, 2002, at 08:23 PM, Enigmarelle Development wrote:
First of all, you're trying to insert the displayView NSTextView itself into
htmlView... Then you're trying to unarchive it back into an NSData*, which
you just archived it into... I'm not surprised it's not working ;)
Try something like:
NSData *htmlData=[NSArchiver archivedDataWithRootObject:[[displayView
textStorage] copy] ];
NSAttributedString *htmlString = [NSUnarchiver unarchiveObjectWithData:htmlData]
;
[[htmlView textStorage] setAttributedString:htmlString]; //setString only
takes a NSString
But in any case, this is a lot of work to go through... Why archive it? You
have a NSAttributedString and you want to end up with a NSAttributedString.
Just do
[[htmlView textStorage] setAttributedString: [[displayView textStorage] copy]
];