出現 invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific 問題的一種可能性

在修改公司老版本項目代碼的時候,偶然發現了在我點選某一按鈕準備Push至到下一個頁面的時候,項目發生的崩潰,Crash Log顯示爲

invalid mode ‘kCFRunLoopCommonModes’ provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
libc++abi.dylib: terminate_handler unexpectedly threw an exception

既然是push時造成的問題,那麼我就直接從產生push時的操作開始打斷點,發現代碼中有一行

[self performSegueWithIdentifier:@"pushToNext" sender:@"param"];

哦? 看來是通過storyboard進行頁面切換的,而且這個sender是用來傳值的,那麼,就單單這一行,我怎麼知道這個sender傳遞的數據是要給誰用呢,翻了下文檔,發現要是通過這個方法進行push和傳值,還需要對這個方法進行override,那麼

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if([segue.identifier  isEqual: @"pushToNext"]) {
        pushViewController *vc = segue.destinationViewController;
        vc.param = sender;
    }
}

這樣就對了,需要push的目標vc找到了,傳遞的參數也有了該去的地方,還有,這個方法不通過前面調用是不會觸發的

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章