ios notify 用例

 NSLog(@"这个值=%f",_slider.value);

    self.textsize=_slider.value;

    //广播

    NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:self,@"edit", nil];

    NSNotificationCenter *nc=[NSNotificationCenter defaultCenter];

    NSNotification *notify=[NSNotification notificationWithName:@"FontSettings" object:self userInfo:dict];

    [nc postNotification:notify];

 

-(void)registerBcast

{

    NSNotificationCenter *nc =[NSNotificationCenter defaultCenter];

    [nc addObserver:self selector:@selector(recvBcast:) name:@"FontSettings" object:nil];

}

-(void)recvBcast:(NSNotification *)notify

{

    NSDictionary *dict=[notify userInfo];

    label.font=[UIFont systemFontOfSize:[[dict objectForKey:@"edit"] textsize]];

}

你可能感兴趣的:(ios notify 用例)