Re: newbie notification question.
Re: newbie notification question.
- Subject: Re: newbie notification question.
- From: Ondra Cada <email@hidden>
- Date: Thu, 28 Mar 2002 20:14:51 +0100
On Thursday, March 28, 2002, at 05:59 , Greg Jackson wrote:
- (void) awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(controlTextDidChange:)
name:@"NSControlTextDidChange" object:nil];
}
My controlTextDidChange function is never called. I assume that I have
not correctly added my object class.
You did; you just misnamed the notification. That's why its better to use
the predefined strings -- what you wanted was
- (void) awakeFromNib { // okay
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(controlTextDidChange:)
name:NSControlTextDidChangeNotification object:nil];
}
This one should work.
- (void) awakeFromNib { // works (probably, not tested), but IS WRONG!
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(controlTextDidChange:)
name:@"NSControlTextDidChangeNotification" object:nil];
}
This one *probably* too, but is weak, might contain an uncatched typo
easily, and besides you can't be sure anyway that the notification name is
not changed.
I tried changing the name to various messages that I saw in the
documentation.
Please point me in the right direction.
Part of my problem is that I am coming to cocoa from powerplant. In
powerplant when I had a problem like this one, I could tell by looking in
the debugger where I made my mistake, what should I have been looking for
in the debugger to give me a clue as to what I did wrong above?
This time gdb would reveal nothing; you need to check documentation for
the right name.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.