Saturday, 29 August 2015

Use the object property of NSNotificationcenter

 NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:
                              PhoneNoTxtField.text, @"phone",
                              EmailTxtField.text, @"email",
                              nil];        
 [[NSNotificationCenter defaultCenter] postNotificationName:@"phone_email"
                                                            object:self

                                                          userInfo:dict]; 


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

- (void)addPhoneEmail:(NSNotification *)notification {    
    NSLog(@"email: %@",[notification.userInfo objectForKey:@"email"]);
    NSLog(@"phone: %@",[notification.userInfo objectForKey:@"phone"]);
}

(OR)

[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadTable" object:self.TxtGroupName.text];


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

-(void)rightMenuaction:(NSNotification *)note
{
      NSLog(@"reload table %@",note.object);
}

No comments:

Post a Comment