• 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: inserting graphics into NSString output
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inserting graphics into NSString output


  • Subject: Re: inserting graphics into NSString output
  • From: Scott Anguish <email@hidden>
  • Date: Mon, 13 May 2002 06:06:29 -0400

On Saturday, May 11, 2002, at 10:51 PM, Nathan Lee wrote:

Hello, I'm a newbie, and I'm trying to learn the NSString system. Could
someone help me out with inserting an image into a string?

You can't insert an image into an NSString.. only NSAttributedString can hold an NSTextAttachment

You can make a new NSAttributedString with an attachment by calling +attributedStringWithAttachment: and passing the NSTextAttachment as the argument.

Then, you can append the NSAttributedString onto the textBox's textStorage using

[[textBox textStorage] appendAttrbutedString:myStringWithTheAttachment]


- (IBAction)appendAnImage:sender;
{
NSTextAttachment *theAttachment;
NSFileWrapper *theWrapper = [[[NSFileWrapper alloc] initWithPath:[[NSBundle mainBundle] pathForResource:@"image" ofType:@"tiff"]] autorelease];
theAttachment = [[[NSTextAttachment alloc] initWithFileWrapper:theWrapper] autorelease];
[[theTextView textStorage] appendAttributedString:[NSAttributedString attributedStringWithAttachment:theAttachment]];
}
_______________________________________________
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: inserting graphics into NSString output
      • From: Douglas Davidson <email@hidden>
References: 
 >inserting graphics into NSString output (From: Nathan Lee <email@hidden>)

  • Prev by Date: ANN: GyazMail 0.1.0
  • Next by Date: What does NSURL setProperty:forKey: do?
  • Previous by thread: inserting graphics into NSString output
  • Next by thread: Re: inserting graphics into NSString output
  • Index(es):
    • Date
    • Thread