Error EXC_BAD_ACCESS (code=2, address=...)
matejhocevar opened this issue · 2 comments
matejhocevar commented
Hey!
I'm new to iOS development. And I found this plugin very interesting, so I want to implement it. But I stumble upon a problem that I cannot resolve.
My code like looks like this:
...
import HGPlaceholders
class MyViewController: BaseViewController {
@IBOutlet var myTableView: TableView!
override func viewDidLoad() {
super.viewDidLoad()
...
configureTableView()
...
}
}
extension MyViewController: UITableViewDelegate, UITableViewDataSource {
func configureTableView() {
myTableView.delegate = self
myTableView.dataSource = self
myTableView.placeholderDelegate = self // <- ERROR: EXC_BAD_ACCESS (code=2, address=0x1b4b2ec80)
..
myTableView.register(UINib(nibName: "MyCell", bundle: nil), forCellReuseIdentifier: "MyItemCell")
...
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
...
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
...
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
myTableView.deselectRow(at: indexPath, animated: true)
myTableView.showLoadingPlaceholder()
}
}
I got an error EXC_BAD_ACCESS (code=2, address=0x1b4b2ec80)
at the line myTableView.placeholderDelegate = self
.
Can someone help me?
Thank you
Idomo commented
Where did you implement PlaceholderDelegate
?
You can’t say that the placeholderDelegate = self
if self
doesn’t implement the delegate at any extension.
Binusz commented
You need to call placeholderDelegate optional.
like that;
myTableView?.placeholderDelegate = self