iOS关于通知传值Bool类型的注意点


比如:

    [[NSNotificationCenter defaultCenter] postNotificationName:@"Notification_Name" object:nil userInfo:@{@"paramName":@YES}];

  

再接收通知获取参数处理时:

-(void)Handle:(NSNotification *)notification{
    BOOL isFirst = notification.userInfo[@"isFirstLocation"];
    NSLog(@"isFirst:%d",isFirst);
    //这里不能直接写 if (isFirst),必须如下写法
    if (isFirst == 1) {
        //表示Yes
    }
}

  

if判断里,必须写 == 1/0,来判断yes/no

 

小细节,别忽略了哦


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM