Re: Writing an image from a text view to file [SOLVED]
Re: Writing an image from a text view to file [SOLVED]
- Subject: Re: Writing an image from a text view to file [SOLVED]
- From: Jeremy Dronfield <email@hidden>
- Date: Fri, 12 Mar 2004 21:10:16 +0000
On 11 Mar 2004, at 21:59, Jeremy Dronfield wrote:
On 11 Mar 2004, at 12:08 am, Mark Onyschuk wrote:
What you need to do is two things. First, you'll need to walk the
attributed string looking for attributes of the attachment type. The
value of the attribute is an NSFileWrapper that represents the image.
First walk the string, pulling out the attachments and saving them
where you will.
The trouble is, in the situation I described (where the content of the
view's text storage is derived from encrypted data), [attachment
fileWrapper] returns NULL. It only appears to work where there is an
original image file on disk.
I came up with the solution. Instead of accessing the textStorage
directly, I pass it into an attributed string as RTFD data:
NSMutableAttributedString *textString = [[NSMutableAttributedString
alloc] initWithRTFD:[[textView textStorage]
RTFDFromRange:NSMakeRange(0, [[entryView textStorage] length])
documentAttributes:NULL] documentAttributes:NULL];
This way, [attachment fileWrapper] returns an image which can be
written to disk, regardless of whether there is an original source file
for the image.
-Jeremy
-----------------------------------------------------------
"The man who believes a thing is true because he feels it in his bones,
is not really very far removed from the man who believes it on the
authority of a policeman's truncheon." (E.M. Forster)
-----------------------------------------------------------
email@hidden
theLocustFarm.net:
- fractious fiction at
http://freespace.virgin.net/jeremy.dronfield
-----------------------------------------------------------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.