• 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
Re: Writing an image from a text view to file [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Re: Writing an image from a text view to file (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: RE: Memory management in a thread
  • Next by Date: Re: Odd binding issue
  • Previous by thread: Re: Writing an image from a text view to file
  • Next by thread: Re: Thread safety of NSPipe
  • Index(es):
    • Date
    • Thread