views:

28

answers:

1

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?

A: 

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
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
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