0

I am trying to post a notification without much success! I can do it ok for the keyboard without issue but now am trying a custom one as follows:

In my rootview I have this

.h

-(void) allowEdits:(NSNotification *)notification;

.m

//this section is run in method to present the passcode entry form


[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(allowEdits:) name: @"PasscodeOK" object:nil];

PasscodeEntryViewController *vc = [[PasscodeEntryViewController alloc]
init];

[self presentModalViewController: vc animated:YES];

[vc release];


// and this is the response to the notification

-(void) allowEdits:(NSNotification *)notification {

    NSLog(@"notification fired");
}


// in the vc instance I have this to notify passcode was ok

[[NSNotificationCenter defaultCenter]
postNotificationName:@"PasscodeOK" object:nil];

[self dismissView];

But the allowEdits never gets called?

Jasarien
  • 58,279
  • 31
  • 157
  • 188
user7865437
  • 812
  • 14
  • 28

1 Answers1

0

Could you try posting your notification with:

[[NSNotificationCenter defaultCenter] postNotificationName:@"PasscodeOK" object:self];

As sender take the vc instance (self) instead of nil. Maybe that's solving your problem.

schaechtele
  • 1,130
  • 1
  • 9
  • 12
  • Hi, yeah tried that before but no joy! The problem is the method to call is in the parent and the notification is posted in the child. From what I can see the addObserver in the parent is just being ignored! It is driving me crazy!!! I just cannot understand why it wont work! – user7865437 Apr 08 '10 at 12:08
  • Well bugger! I found it after all this time! When I was implementing notifications weeks ago I included in the viewDidDisappear method a call to remove observers! So no sooner had I added it...it was removed! DOH! – user7865437 Apr 08 '10 at 12:34