Re: attributed strings and embedded images.
Re: attributed strings and embedded images.
- Subject: Re: attributed strings and embedded images.
- From: Douglas Davidson <email@hidden>
- Date: Mon, 15 Apr 2002 16:23:33 -0700
On Monday, April 15, 2002, at 04:11 PM, email@hidden wrote:
I have iterated through the textStorage and see the attachment, but all
I get is the name 'Name "pastedGraphic.tiff"'...
- (void)logAttachments:(NSAttributedString *)s
{
NSRange fullRange = NSMakeRange(0, [s length]);
while (fullRange.length > 0) {
NSRange effectiveRange;
id attr = [s attributesAtIndex:fullRange.location
longestEffectiveRange:&effectiveRange inRange:fullRange];
fullRange = NSMakeRange(NSMaxRange(effectiveRange),
NSMaxRange(fullRange) - NSMaxRange(effectiveRange));
NSLog(@"attr = %@", attr);
}
}
output: attr = {NSAttachment = Name "pastedGraphic.tiff"; }
How do I get a handle on the NSTextAttachment object behind it?
First, you don't need to do a longestEffectiveRange:. Each text
attachment should be represented by a single NSAttachmentCharacter
(=0xfffc), with an attribute NSAttachmentAttributeName, whose value is
an NSTextAttachment. The attachment has a file wrapper (see
NSTextAttachment.h), which represents the file, or in this case its data
(see NSFileWrapper.h). You can substitute a different file wrapper if
you like.
What you are seeing here is the attachment's description, which prints
the file wrapper's preferredFilename.
Douglas Davidson
_______________________________________________
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.