Call a function using Notification in Xcode


Step 1: Post Notification from class A.

NSString *data=@”Demo”;[[NSNotificationCenter defaultCenter] postNotificationName:@”golferUpdate” object:nil userInfo:data];if you do not want to pass data use 

[[NSNotificationCenter defaultCenter] postNotificationName:@golferUpdate object:nil];

Step 2: Register Notification in Class B.

[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(GetData:) name:@”golferUpdate”object:nil];

Step 3: Add function GetData

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

    NSDictionary *dict = [notification userInfo];

// write your code Here

}

 

 

Step 4: Enjoy Coding………..

Best Of Luck.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: