M
M
Maxim Globak2015-10-19 15:31:47
iOS
Maxim Globak, 2015-10-19 15:31:47

Why is a delegated function not being called in swift?

Good afternoon! Delegation question. Why is the delegate not executed in MainTableViewController? gives no errors.
You can’t put segue here, I’ve been suffering for the second day.5ad9dbbcee8742cb8de2bf18b97a9bc4.png6f3b62736e804136baf6c8df919dbae1.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Tikhonov, 2015-10-19
@tikhonov666

First, this is strange:
var delegate: sideBarDelegate!
...
self.delegate?.sidebarParse
Second, the problem is that you don't store the resulting sideBarTVC in MainTableTVC. On exit from the function, it is removed from memory.
Can you do it like this

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if let identifier = segue.identifier {
            if identifier == "SideBarTVC" {
                let vc = segue.destinationViewController
                vc.delegate = self
            }
        }
}

And do not forget to make the appropriate settings in the storyboard

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question