Re: Appending string to NSTextView crashing app
Re: Appending string to NSTextView crashing app
- Subject: Re: Appending string to NSTextView crashing app
- From: Evan Moseman <email@hidden>
- Date: Fri, 27 Apr 2007 08:45:19 -0400
Very interesting, I didn't think of that. So maybe the notification
is not getting managed (memory wise) because of the functions that
are getting called? Not sure, but interesting.
Thanks for your help!
--
Evan
On Apr 25, 2007, at 11:27 PM, PGM wrote:
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