• 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: attributed strings and embedded images.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: attributed strings and embedded images.
      • From: email@hidden
References: 
 >Re: attributed strings and embedded images. (From: email@hidden)

  • Prev by Date: Re: NSFileManager and aliases
  • Next by Date: Re: attributed strings and embedded images.
  • Previous by thread: Re: attributed strings and embedded images.
  • Next by thread: Re: attributed strings and embedded images.
  • Index(es):
    • Date
    • Thread