Creating a string with attachements from thin air... and an image...
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] initWith
Data: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.