initWithURL/NSattributedStrings and NSData
initWithURL/NSattributedStrings and NSData
- Subject: initWithURL/NSattributedStrings and NSData
- From: Darin Duphorne <email@hidden>
- Date: Mon, 28 Jan 2002 23:56:05 -0600
I render html in a NSTextView as follows:
NSAttributedString *attrStr=[[NSAttributedString alloc] initWithURL:
fileURL documentAttributes:&attributes];
[[displayView textStorage] setAttributedString:attrStr];
This renders the html beautifully in a NSTextView. I can make modifications,
etc. I try to recover the html into a second view as follows:
NSData *htmlData=[NSArchiver archivedDataWithRootObject:displayView];
htmlString=[[NSString alloc] initWith
Data:htmlData encoding:NSASCIIStringEncoding]
;
[htmlView setString:htmlString];
However, the resulting text displayed is some sort of textual representation
of the NSData (a portion is below). Are there any methods that will convert
this to html?
typedstreamh@NSTextTemplateFNSViewTemplate.NSView)NSResponder
NSObjecti@@@@ffffffffNSMutableSetNSSetIRNSString
+NSTypedFilenamesPboardType:png!NSTypedFilenamesPboardType:'TPIC'
NSTypedFilenamesPboardType:PCTNSTypedFilenamesPboardType:ICONSTypedFilenamesPboardType:
pict!NSTypedFilenamesPboardType:'PDF *
*
*
*
dFilenamesPboardType:'PICT'NSTypedFilenamesPboardType:icnsOV
OVNSText
NSMutableDataNSDataQ[337c]rtfd.TXT.rtf+~
#TXT.rtf6v{\rtf1\mac\ansicpg10000\
cocoartf100
{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\
tx6160\tx6720
\f0\fs24 \cf0 This is a test sentence.}NSColorcff$O
V$O###########