Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error EXC_BAD_ACCESS (code=2, address=...) #44

Open
matejhocevar opened this issue Aug 27, 2018 · 2 comments
Open

Error EXC_BAD_ACCESS (code=2, address=...) #44

matejhocevar opened this issue Aug 27, 2018 · 2 comments

Comments

@matejhocevar
Copy link

matejhocevar commented Aug 27, 2018

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
Copy link
Contributor

Idomo commented Oct 25, 2018

Where did you implement PlaceholderDelegate?
You can’t say that the placeholderDelegate = self if self doesn’t implement the delegate at any extension.

@Binusz
Copy link

Binusz commented Oct 29, 2018

You need to call placeholderDelegate optional.
like that;
myTableView?.placeholderDelegate = self

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants