Re: NSAttributedString with embedded image
Re: NSAttributedString with embedded image
- Subject: Re: NSAttributedString with embedded image
- From: "M. Uli Kusterer" <email@hidden>
- Date: Mon, 28 Mar 2005 16:58:05 +0200
Here's how to append an image to an NSMutableAttributedString:
-(void) appendImage: (NSImage*)img
{
NSFileWrapper* fwrap = [[[NSFileWrapper alloc]
initRegularFileWithContents: [img TIFFRepresentation]] autorelease];
NSString* imgName = [img name];
if( !imgName )
imgName = @"image";
imgName = [imgName stringByAppendingPathExtension: @".tiff"];
[fwrap setFilename: imgName];
[fwrap setPreferredFilename: imgName];
NSTextAttachment* ta = [[[NSTextAttachment alloc]
initWithFileWrapper: fwrap] autorelease];
[self appendAttributedString: [NSAttributedString
attributedStringWithAttachment: ta]];
}
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden