[英]When does a protocol function get called?
我在viewController类中采用了一个协议,并定义了它的方法(只有一个方法)。 该方法假定更新最初为空的数组。 这是一些代码。
var contact = ContactList()
func getContactData( entry: ContactListEntry ) {
contact.updateEntry(entry)
}
也
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
self.detailViewController?.delgate = self
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
cell.textLabel!.text = contact.entries [indexPath.row].firstName
return cell
}
产生致命错误:无法索引空缓冲区(lldb)
我的问题是,getContactData()在什么时候被调用? 我需要在tableView函数之前调用它,以便可以使数组中包含某些内容。
当iOS需要显示单元格时,将调用cellForRowAtIndexPath
。 UITableViewDataSource
其他方法也是如此
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.