use of NSUnarchiver
use of NSUnarchiver
- Subject: use of NSUnarchiver
- From: email@hidden
- Date: Tue, 29 Jan 2002 22:19:30 -0800
I have NSAttributedString content in a NSTextView that I want to move
to a
different NSTextView. I am trying to use an NSArchiver and
NSUnarchiver to
achieve this move via an NSData. It doesn't work.
NSData *htmlData=[NSArchiver
archivedDataWithRootObject:displayView];
htmlData=[NSUnarchiver unarchiveObjectWithData:htmlData];
htmlString=[[NSString alloc] initWithData:htmlData
encoding:NSASCIIStringEncoding]
;
[htmlView setString:htmlString];
Hmm. If this NSAttributedString content is coming from HTML.framework
(if it is generated by the AppKit from HTML data, that is), this may be
doomed to failure. What you might need to do, for reasons too
complicated to get into here, is archive to *RTF* data and back out
again. Use the textview (or is it textstorage?) methods that let you
get and set RTF (or RTFD) data for a range.
If the attributed string is not coming from the HTML framework, then
perhaps there is some other issue at work here. :-> Perhaps the code
you copied into your e-mail is not exactly the code you're trying to
run, but... I notice you seem to be archiving a view, but using the data
to try to unarchive into an NSString...
Ben Haller
Stick Software