The code snippet you provided below looks reasonable, I don't see anything obviously wrong with it...
This message is indeed coming from an exception, so putting a breakpoint in the debugger on -[NSException raise] as Uli indicated should get you a backtrace of where the problem is occurring.
If you'd like to see what the string is at that point, you can go up to the stack frame containing addAttribute:value:range:, and do
po $r3
($r3 contains self)
This might indicate whether there's anything corrupt with the text itself. To see what the attribute being set is, try
po $r5
($r5 contains the first argument)
Don't know if this will help. Ali
Begin forwarded message:
From: Pierre Chatel <email@hidden> Date: March 30, 2005 8:39:46 PST To: Cocoa Developer <email@hidden> Subject: NSConcreteNotifyingMutableAttributedString
Hi there !
i have this NSTextField in my application, i enabled it for RTF and image support. So now i can drag images in the middle of the text i'm writing. I also added a standard font panel to my application. Here comes the problem: if i select a piece of text with pictures and try to change font attributes with the font panel, i get this error and the NSTextView begins to behave strangely:
NSConcreteNotifyingMutableAttributedString addAttribute:value:range:: nil value
So i suppose that's it's somehow related to trying to apply font attributes to a pictures, and that "value" or "range" must be nil, causing the error. I looked at the code of TextEdit and i didn't find anything related to this issue: when you are in RTF mode in TextEdit you can apply font settings to text and images at the same time without problems.
Here is an extract of the code i'm using to create an empty NSTextView:
textView = [[[NSTextView alloc] initWithFrame:rectSave] autorelease]; [textView setAutoresizingMask:oldMask]; [textView setRichText:YES]; [textView setImportsGraphics:YES]; NSDictionary *textAttributes = [self defaultTextAttributes]; [textView setTypingAttributes:textAttributes]; [[[textView textStorage] mutableString] setString:@""];
Please help, as i'm really confused with this issue. Thanks !
|