NSNotificationCenter 实现

    接收

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

     

   

-(void)receive:(NSNotification *)center{

    NSDictionary *info = [center userInfo];

    NSNumber *number=[info objectForKey:@"one"];

    NSLog(@"%@",number);

    NSLog(@"测试成功");

 

}

 

 

 

 

通知:

   NSDictionary *p = [[NSDictionary alloc] initWithObjects:@[@1,@2,@3] forKeys:@[@"one",@"two",@"three"]];

 

        [[NSNotificationCenter defaultCenter] postNotificationName:@"zhibintest" object:self userInfo:p];

 

posted @ 2014-11-27 20:09  銱ル╬鎯噹  阅读(103)  评论(0编辑  收藏  举报