2014-07-24 75 views
1

我得到一個錯誤:「EXC_BAD_ACCESS(code = 1,address = 0xffffffffffffffffff8)」當我試圖設置我的UITableViewCell的委託。在Xcode beta 4中設置UITableViewCell委託時崩潰

這裏是我的UITableViewCell:

protocol MyCellDelegate { 
    func onButtonClicked(theCell : MyCell) 
} 

class MyCell: UITableViewCell { 

    @IBOutlet weak var lblTitle: UILabel! 

    var delegate : MyCellDelegate? 

的UIViewController中,其中包括誰使用的tableview單元的實現代碼如下:

func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { 

    let cell = tableView.dequeueReusableCellWithIdentifier("MyCell") as MyCell 
    cell.lblTitle.text = ... 
    cell.lblDescription.text = ... 
    cell.delegate = self // ***Crashes*** here 

看來相同的代碼工作貝塔3.任何人都可以幫助嗎? (我不知道如何爲Swift調試這種錯誤,因爲所有命令如po根本不起作用。)

+0

愚蠢的問題......但'self'實現了MyCellDelegate協議嗎? – ansible

+0

當然可以。 –

回答

0

添加@objc解決了這個問題。

@objc protocol MyCellDelegate { 
    func onButtonClicked(theCell : MyCell) 
}