• 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
Creating a string with attachements from thin air... and an image...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating a string with attachements from thin air... and an image...


  • Subject: Creating a string with attachements from thin air... and an image...
  • From: Renaud Boisjoly <email@hidden>
  • Date: Fri, 28 Mar 2003 09:11:31 -0500

Hi!

I'm trying to import PICT image files into a textView and I'm facing strange issues... here is my documented code:


myData = [thisImporter dataForType:'PICT' Id:1];
NSImage *newImage = [[NSImage alloc] initWithData:myData];
NSLog(@"PICT image: %@",newImage); //Things look right at this point...

id myWrapper = [[NSFileWrapper alloc] initWithPath:[[NSBundle mainBundle] pathForResource:@"new" ofType:@"tiff"]];

//I'm using a default filewrapper, I haven't figured-out how to create an NSTextAttachement completely programmatically, perhaps this is my issue?

id myAttachment = [[NSTextAttachment alloc] initWithFileWrapper: myWrapper];
NSTextAttachmentCell *myCell = [[NSTextAttachmentCell alloc] initImageCell:newImage];
[happyAttachment setAttachmentCell:myCell];
NSAttributedString *myString = [NSAttributedString attributedStringWithAttachment: myAttachment] ;
NSLog(@"Text: %@",myString);
[[[myTextView textStorage] appendAttributedString:myString ];

All I get in the final TextView is a blank. If I do not try to substitute the NSTextAttachementCell, I still get the original graphic (new.tiff).

I also tried programmatically, without a default FileWrapper, but I would still only get blanks... I was using something like:
NSTextAttachment *myAttachement = [[NSTextAttachment alloc] init];
NSTextAttachmentCell *myCell = [[NSTextAttachmentCell alloc] initImageCell:newImage];
[myAttachement setAttachmentCell:myCell];
NSAttributedString *myString = [NSAttributedString attributedStringWithAttachment:happyAttachment] ;

But that too doesn't work


I'm sure I'm missing something trivial... any clues ?

Arby
_______________________________________________
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: Creating a string with attachements from thin air... and an image...
      • From: Renaud Boisjoly <email@hidden>
  • Prev by Date: Re: Constraining window resize?
  • Next by Date: reasonable way of avoiding using autorelase?
  • Previous by thread: Re: Constraining window resize?
  • Next by thread: Re: Creating a string with attachements from thin air... and an image...
  • Index(es):
    • Date
    • Thread