iPhoneアプリのTableView表示でエラー「unrecognized selector sent to instance」
Swiftでテストアプリ開発している時に遭遇。
設定が間違っていると以下のようなエラーが出る。
2014-11-13 01:28:13.470 iOSApp[7885:126131] -[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fa282d76590 2014-11-13 01:28:13.475 iOSApp[7885:126131] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fa282d76590'
これはmain.storyboardでdataSourceとdelegateの接続先をViewにしてしまうと発生するエラー。接続先はView Controllerにするのが正しい。
画面デザインのところじゃなくて、リスト表示になっているところの上の方にあるView Controllerに対してドラッグ&ドロップで接続する。