Using Notification You can Make Interact Two Classes.
In ClassA You Need To Register Your Notification By Using Lines Of Code
In ClassA.h
-(void)getNotification:(NSNotification *)notify;
In ClassA.m File
-(void)viewDidLoad
{
......
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getNotification:) name:@"Notification_Name" object:nil];
.....
}
# pragma mark Get Notification
-(void)getNotification:(NSNotification *)notify
{
NSLog(@"Notify User info %@",notify.object);
Array1 = notify.object;
}
To Post Notifcation From ClassB You Need To Write The Following Lines Of Codes
ClassB.m File
After Completing Required Action You Have Post Notification
-(IBAction)doneButton:(id)sender
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"Notification_Name" object:selectedArray userInfo:nil];
}
No comments:
Post a Comment