• 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
Correct way to insert an image into NSTextView.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Correct way to insert an image into NSTextView.


  • Subject: Correct way to insert an image into NSTextView.
  • From: Gus Mueller <email@hidden>
  • Date: Fri, 6 Feb 2004 18:05:26 -0800

I've got a program where I'm inserting an image from the filesystem into
a NSTextView. However, after the image is inserted, the file is still
held onto (by the textview I think). So if a user tries to delete the
file via the trash, they will get a message saying it's still in use.

Here's the snippet of code I'm using:

NSFileWrapper *filew = [[[NSFileWrapper alloc]
initWithPath:@"path/to/file.pdf"] autorelease];
NSTextAttachment *fileAttatchment = [[[NSTextAttachment alloc]
initWithFileWrapper:filew] autorelease];
NSAttributedString *fileAttString = [NSAttributedString
attributedStringWithAttachment:fileAttatchment];
[textView insertText:fileAttString];

Is there another way I should be doing this?

thanks,

-gus

--
August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.com/
_______________________________________________
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.

  • Follow-Ups:
    • Re: Correct way to insert an image into NSTextView.
      • From: Gus Mueller <email@hidden>
  • Prev by Date: Using NSSearchField and remaining Jaguar compatible?
  • Next by Date: Question about Outline View code in Documentation
  • Previous by thread: Re: Using NSSearchField and remaining Jaguar compatible?
  • Next by thread: Re: Correct way to insert an image into NSTextView.
  • Index(es):
    • Date
    • Thread