0

これは、プレイグラウンドで正しく機能UITableViewする単純なコードです。

import UIKit

class MyDataSuorce : NSObject, UITableViewDataSource {
    func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
    {
        let cell = UITableViewCell(style: .Value2, reuseIdentifier: nil)

        cell.textLabel.text = "Row #\(indexPath.row)"

        return cell;
    }

    func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
    {
        return 4
    }

}


let list = UITableView(frame:CGRectMake(0,0,300,300), style: .Plain)
let d = MyDataSuorce()
list.dataSource = d
list.reloadData()

しかし、私が最初にこのコードを試したとき、それは機能せず、空のUITableView.

let list = UITableView(frame:CGRectMake(0,0,300,300), style: .Plain)
list.dataSource = MyDataSuorce()
list.reloadData()

2 番目のコードの何が問題になっていますか?

編集:

これは のコンソール出力ですlist.dataSource = MyDataSuorce():

プレイグラウンドの実行に失敗しました: エラー: エラー: シンボルを検索できませんでした: _memmove

4

1 に答える 1

1

「なんで? 」が解決するかも・・・

私は、それは迅速な変数の寿命についてだと思います。(正しい?)

MyDataSource()2 番目のコードでは、返されたオブジェクト (by ) がそのコード行の間に存在することを忘れていました。

于 2014-07-11T11:01:11.000 に答える