• 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
use of NSUnarchiver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: hey, Cocoa, don't touch that cursor
  • Next by Date: Re: Initializing an Array
  • Previous by thread: Re: use of NSUnarchiver
  • Next by thread: about UDP
  • Index(es):
    • Date
    • Thread