iOS 通知带参数

来源:互联网 发布:朗塞特 知乎 编辑:程序博客网 时间:2024/05/22 10:26

1、带参数


//注册通知//方法实现

    [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(updatCardInfo:)name:updateCardInfoNotificationobject:nil];


//方法实现

-(void) updatCardInfo :(NSNotification*) notification

{

    接收参数 = [notificationobject];//通过这个获取到传递的对象 

}

//发送通知

   [[NSNotificationCenterdefaultCenter] postNotificationName:updateCardInfoNotificationobject:参数];




2、不带参数

//注册通知

    [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(deviceDamage)name:VDBlueToothDamageNotificationobject:nil];

//方法实现

-(void)deviceDamage

{

}

//发送通知

   

 [[NSNotificationCenterdefaultCenter] postNotificationName:VDBlueToothDamageNotificationobject:nil];


0 0
原创粉丝点击