2014-07-24 77 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) 
}