Test Test - 1 year ago 88
Objective-C Question

How to add Notification Observer

I am new in programming and I have no more idea of application developing. So, How to add notification observer and how to define, called and remove.

Answer Source

Define Notification Observer:

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

- (void)myAction:(NSNotification *)notif
 NSLog(@"Received Data for Called Notification Observer is :\n %@",notif);


Called Notification Observer:

[[NSNotificationCenter defaultCenter] postNotificationName:@"NOTIFI_OBSER_test" object:@"Pass Value is test"];

and Remove Notification Observer:

[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NOTIFI_OBSER_test" object:nil];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download