美文网首页
iOS Performselector withObject 传

iOS Performselector withObject 传

作者: Faner_NG | 来源:发表于2020-04-09 16:22 被阅读0次

    - (BOOL)connectionRoom:(BOOL)isReconncet:{
    }

    之前这些写,以为调用connectionRoom的参数isReconncet是NO,在debug模式下确实是NO,但是在release模式下参数isReconncet是YES,害的问题查了好久,坑啊

    原因:

    withObject参数传nil才是NO

    传任何其他参数代表YES

    以下是stackoverflow给出的相关解释:

    The simplest way is as follows:

    If you have method

    -(void)doSomething:(BOOL)flag

    and want to performSelecor with flag=NO use

    [object performSelector:@selector(doSomething:) withObject:nil];

    In case of flag=YES you can send any object, for example, @YES - number from bool

    [object performSelector:@selector(doSomething:) withObject:@YES];

    Note: don't use @NO ! Only nil will be interpreted as NO in your method with bool argument.

    原文 https://stackoverflow.com/questions/7075620/iphone-performselector-with-bool-parameter

    相关文章

      网友评论

          本文标题:iOS Performselector withObject 传

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