• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: newbie notification question.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: newbie notification question.
      • From: Jonathan Feinberg <email@hidden>
References: 
 >newbie notification question. (From: Greg Jackson <email@hidden>)

  • Prev by Date: Re: Where to start?
  • Next by Date: [ANN] DockDisks 1.0b1 released
  • Previous by thread: newbie notification question.
  • Next by thread: Re: newbie notification question.
  • Index(es):
    • Date
    • Thread