Re: Appending string to NSTextView crashing app
Re: Appending string to NSTextView crashing app
- Subject: Re: Appending string to NSTextView crashing app
- From: PGM <email@hidden>
- Date: Wed, 25 Apr 2007 23:27:36 -0400
On 25-Apr-07, at 22:42 PM, Evan Moseman wrote:
A button is linked to:
- (IBAction)startAppButton:(id)sender
{
[self appendString:@"Starting notification event capture..."
toView:applicationTextView];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(appNotificationObserver:)
name:nil object:nil];
}
The selector is this function:
- (void)appNotificationObserver:(NSNotification *)note
{
NSLog(@"app note: %@", [note name]);
[self appendString:[note name] toView:applicationTextView];
}
I do not know if this is causing the crash, but it seems to me that
something akward should be happening here. You are registering your
object to receive any notification sent by any object. You then place
this notification in an NSTextView. This causes a
NSTextDidChangeNotification to be sent, which in return is placed
inside your NSTextView. This causes an infinite loop of
notifications. If you only use NSLog, you don't have this problem as
no notification is sent upon logging.
Cheers, Patrick
_______________________________________________
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