How to use NSNotification

后端 未结 2 965
再見小時候
再見小時候 2020-12-18 04:51

In my application there is two viewControllers as FirstViewController and DetailViewController. When tap on a table cell, it navigate to Det

2条回答
  •  一个人的身影
    2020-12-18 05:36

    -(void)viewDidLoad {
    
    [NSNotificationCenter defaultCenter];
    NSNotification* notification = [NSNotification notificationWithName:@"MyNotification" object:self];
    [[NSNotificationCenter defaultCenter] postNotification:notification];  
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (objFirstViewController) name:@"MyNotification" object:nil];
    
    }
    
    
    -(IBAction) save{
    
    [[NSNotificationCenter defaultCenter] postNotificationName:MyNotification object:sender];
    
    //this will go to where you implement your selector objFirstViewController.
    
    }
    
    -(void)objFirstViewController:(NSNotification *)notification {
    
    }
    

提交回复
热议问题