2017-04-20 11 views
-1

我收到無法識別的選擇發送到實例0x1559a8200

終止應用程序由於未捕獲的異常「NSInvalidArgumentException」,原因是:無法識別的選擇發送到實例0x1559a8200

錯誤引用的選擇信息是:

[SoloCheck.DirectorFormCell seeDirectorReportDidTap:] 

的代碼添加目標如下:

cell.seeDirectorReport.addTarget(cell.seeDirectorReport, action: #selector(CompanyFreeReportVC.seeDirectorReportDidTap(_:)), forControlEvents: .TouchUpInside) 

該法的執行情況如下:

func seeDirectorReportDidTap(sender: UIButton) { 
    self.performSegueWithIdentifier("OpenCompanyDocumentsSegue", sender: sender.tag) 
} 

我改變了代碼

cell.seeDirectorReport.addTarget(self, action: #selector(CompanyFreeReportVC.seeDirectorReportDidTap(_:)), forControlEvents: .TouchUpInside) 

和誤差保持不變:

2017-04-20 15:53:19.806 SoloCheck[12035:1267396] Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UISearchController: 0x15ef187a0>) 
2017-04-20 15:53:19.854 SoloCheck[12035:] <GMR/INFO> App measurement v.2003000 started 
2017-04-20 15:53:19.854 SoloCheck[12035:] <GMR/INFO> To enable debug logging set the following application argument: -GMRDebugEnabled (see) 
2017-04-20 15:53:20.009 SoloCheck[12035:1267396] [Crashlytics] Version 3.7.0 (102) 
2017-04-20 15:53:37.786 SoloCheck[12035:1267396] -[SoloCheck.DirectorFormCell seeDirectorReportDidTap:]: unrecognized selector sent to instance 0x15f154600 
2017-04-20 15:53:37.794 SoloCheck[12035:1267396] WARNING: GoogleAnalytics 3.14 void GAIUncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:48): Uncaught exception: -[SoloCheck.DirectorFormCell seeDirectorReportDidTap:]: unrecognized selector sent to instance 0x15f154600 
2017-04-20 15:53:42.837 SoloCheck[12035:1267396] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SoloCheck.DirectorFormCell seeDirectorReportDidTap:]: unrecognized selector sent to instance 0x15f154600' 
*** First throw call stack: 
(0x18324d900 0x1828bbf80 0x18325461c 0x1832515b8 0x18315568c 0x187f77e50 0x187f77dcc 0x187f5fa88 0x187f776e4 0x187f30294 0x187f70820 0x187f6fe1c 0x187f404cc 0x187f3e794 0x183204efc 0x183204990 0x183202690 0x183131680 0x184640088 0x187fa8d90 0x1000b544c 0x182cd28b8) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 
+0

什麼是無法識別的選擇器,它通常是在錯誤消息 – Alistra

+0

[SoloCheck.DirectorFormCell seeDirectorReportDidTap:] - 我也想把一個值放在button標記中,並在seeDirectorReportDidTap方法中檢索是否有可能? –

+0

你的'#selector'指定了一個視圖控制器的方法,但'target'似乎是別的。 「cell.seeDirectReport」引用了什麼? – Rob

回答

1

此錯誤只是告訴你,你的target沒有參考引用您在action中引用的方法。因此,請確定您是否提供了錯誤的目標或錯誤的action

addTarget的第一個參數是實現action選擇器的對象。我從你的#selector(CompanyFreeReportVC.seeDirectorReportDidTap(_:))推斷你已經在你的視圖控制器中實現了seeDirectorReportDidTap。因此,您需要將視圖控制器指定爲addTarget的第一個參數。

+0

我從來沒有使用Swift 2,但不應該選擇器的簽名是不同的?在實際的'seeDirectorReportDidTap'函數聲明中沒有'_',所以選擇器不應該是這樣的:'#selector(CompanyFreeReportVC.seeDirectorReportDidTap(sender :))'? – rmaddy

+0

我看到了某處並嘗試過,但它甚至不會編譯它說'類型'CompanyFreeReportVC'沒有成員'seeDirectorReportDidTap(sender :)' –

相關問題