Appending string to NSTextView crashing app
Appending string to NSTextView crashing app
- Subject: Appending string to NSTextView crashing app
- From: Evan Moseman <email@hidden>
- Date: Tue, 24 Apr 2007 22:29:38 -0400
I'm hoping somebody can help me with this, I'm trying to append text
to an NSTextView using this function:
- (void)appendString:(NSString *)string toView:(NSTextView *)view
{
if (string == nil) { return; }
[view setEditable:YES];
NSString *subString = [[NSString alloc] initWithFormat:@"%@\n",
string];
NSAttributedString *stringToAppend =
[[NSAttributedString alloc] initWithString:subString];
[[view textStorage] appendAttributedString:stringToAppend];
[view setEditable:NO];
}
But, after about 10 strings, the whole app crashes with a seg fault.
I can print the strings using NSLog and it never crashes. Is there
something wrong with the above code? Should I try using bindings?
Any help is greatly appreciated!
Thanks!
--
Evan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden