Table view tooltips crashes when using NSString with attachment characters?
Table view tooltips crashes when using NSString with attachment characters?
- Subject: Table view tooltips crashes when using NSString with attachment characters?
- From: Keith Blount <email@hidden>
- Date: Fri, 1 Sep 2006 01:46:12 -0700 (PDT)
Hello,
I have a table view that displays tooltips using the
delegate methods. These tooltip strings are created by
truncating an NSString that was originally generated
by taking the -string from an NSTextStorage.
However, I am getting a crash whenever the user tries
to display a tooltip that uses a string that was
created from an NSTextStorage that had images in it -
the program hangs forever. It seems that when calling
[aTextStorage string], if the text had images in it,
they are retained as some kind of junk character
within the created NSString, and this causes crashes
whenever trying to draw the string to screen. (I
experienced this crash ages ago in some custom drawing
I did of strings, and fixed it by remvoving all
attachment characters from the text storage before
converting it to a string. However, at the time I just
thought it was a problem with my custom drawing so did
not fix this elsewhere, so now I am in a situation
where the user will have all of these strings lying
around that can crash their app.)
Is there an easy way to strip the attachment
characters from the NSString? I've tried an NSString
category that goes through and strips the attachment
characters, like this:
- (NSString *)stringWithoutAttachments
{
NSMutableString *mString = [[self mutableCopy]
autorelease];
unsigned loc = 0;
unsigned end = [mString length];
while (loc < end) /* Run through the string in terms
of attachment runs */
{
unichar ch = [mString characterAtIndex:loc];
if (ch == NSAttachmentCharacter)
{
[mString replaceCharactersInRange:NSMakeRange(loc,
1) withString:@""];
end = [mString length]; /* New length */
}
else
loc++; /* Just skip over the current character...
*/
}
return mString;
}
But even calling this method to strip the tooltip of
attachment chars doesn't help - the program still
crashes whenever it tries to make a tooltip from a
string made from an attributed string in which there
were originally images.
If anyone has any ideas on how to fix this, I would be
very grateful.
Thanks!
Keith
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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