ios 8+和ios 7 [NSNotificationCenter defaultCenter] postNotificationName差异导致我的应用崩溃

时间:2015-12-01 10:27:46

标签: ios objective-c nsnotificationcenter

我正在使用[NSNotificationCenter defaultCenter]向收听

的所有类发送通知

这样:

#define kReceiveCMD @"RECEIVE_CMD"

我发送到:

   [[NSNotificationCenter defaultCenter] postNotificationName: kReceiveCMD object: cmd userInfo: nil];

我报名参加了聆听:

 - (void) viewWillAppear: (BOOL) animated {

        [super viewWillAppear: animated];
        [[NSNotificationCenter defaultCenter] addObserver: self selector:selector (receiveCMD :) name: kReceiveCMD object: nil];
    }

类正在侦听 - 将要运行(ReceiveCMD :)成功获取对象(cmd)

-(void) receiveCMD:(NSNotification *)obj{
    ServerCommand* cmd = [obj object];

   if (cmd->CommandNo == [CMDVB_ServerIdle commandConst]) {

        NSLog(@"ServerIdle");

        return;


    }

}

最后,当函数结束时, - 应用程序崩溃

Xcode show it this way

错误消息:

  
      
  • [__ NSCFString errorInfo:]:无法识别的选择器发送到实例0x15f1bbb0 2015-12-01 12:17:44.659 HOMismart [403:60b] *   由于未捕获的异常而终止应用程序   'NSInvalidArgumentException',原因:' - [__ NSCFString errorInfo:]:   无法识别的选择器发送到实例0x15f1bbb0'   * 第一次抛出调用堆栈:(0x2d5e8f83 0x37d99ccf 0x2d5ec917 0x2d5eb203 0x2d53a768 0x2d5ab1a1 0x2d51f4ef 0x2df0aa3d 0x262a7d   0x2d5ab1a1 0x2d51f4ef 0x2df0aa3d 0x2df0f31b 0x21e435 0xf3239 0xf2d33   0x21dad7 0xdaa5b 0x1e6617 0x38281833 0x3828181f 0x38281777 0x2d5b38a1   0x2d5b2175 0x2d51cebf 0x2d51cca3 0x32422663 0x2fe6914d 0x153689   0x382a6ab7)libc ++ abi.dylib:以未捕获的异常终止   输入NSException
  •   

这个问题只发生在Ios7上运行的iPhone 4 / 4S,在Ios8 +一切正常工作

0 个答案:

没有答案