通知

作者: 安红唯CC | 来源:发表于2018-05-23 10:14 被阅读0次

    1:

    [[NSNotificationCenter defaultCenter] postNotificationName:@"通知名字"
                                                                                                object:nil                                                         
                                                                                            userInfo:@{字典}];
    

    2:

    - (void)dealloc{
        [[NSNotificationCenter defaultCenter] removeObserver:self];
    }
    

    3:

    - (instancetype)init
    {    self = [super init];
        if (self) {
            //接收通知
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainPageOperation:) name:@"mainPageOperation" object:nil];
        }    return self;}
    

    4:

    -(void)mainPageOperation:(NSNotification *)notification{   if (notification.userInfo[@"字典参数"]) {  }  }
    

    相关文章

      网友评论

          本文标题:通知

          本文链接:https://www.haomeiwen.com/subject/djoljftx.html