2014年8月7日木曜日

Swift エラー Type 'ViewController' does not conform to protocol 'UITableViewDataSource'


ViewController に、UITableView を追加した場合
下記のように、スーパークラスを定義する


class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

ここで
Type 'ViewController' does not conform to protocol 'UITableViewDataSource'

こんなエラーが出て少し嵌ったのでメモ

下記のような必要なメソッドを定義するとエラーは解消される

    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) ->     func tableView(tableView: UITableView!, canEditRowAtIndexPath indexPath: NSIndexPath!) -> Bool {
    func tableView(tableView: UITableView!, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath!) {
    func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {

これ、つい忘れてしまう

環境
Xcode6 beta5

0 件のコメント:

コメントを投稿