0
這裏是我的代碼,編譯器仍顯示出,雖然我寫了實現這兩種方法在Swift中沒有確認協議UITableViewDataSource,爲什麼?
請告訴錯誤爲什麼
進口的UIKit
class FirstViewController: UIViewController , UITableViewDelegate, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return taskMgr.tasks.count
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell : UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "test")
cell.textLabel?.text = taskMgr.tasks[indexPath.row].name
cell.detailTextLabel?.text = taskMgr.tasks[indexPath.row].desc
return cell
}
}
哦,我的天,不能相信這件事發生了我半小時前寫了代碼,並認爲更新Xcode,在更新API更改後,哈哈:)反正感謝很多budy,我認爲可見協議的定義也應該在Xcode中進行更改,但也可以作爲方法的舊簽名顯示。 – Abhi 2014-09-23 20:48:25