Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Problems with delegate #26

Open
KursX opened this issue Jan 13, 2020 · 2 comments
Open

Problems with delegate #26

KursX opened this issue Jan 13, 2020 · 2 comments

Comments

@KursX
Copy link

KursX commented Jan 13, 2020

func colorViewController(_ colorViewCntroller: EFColorSelectionViewController, didChangeColor color: UIColor) does not work.

Because here:
self.delegate?.colorViewController(self, didChangeColor: color)

self.delegate always nil, despite that I set it

I fixed this by deleting weak here:

public WEAK var delegate: EFColorSelectionViewControllerDelegate?

Maybe I did something wrong?

@ebarellar
Copy link

Probably something wrong, the delegate pattern is usually used with weak references in order to avoid a reference cycle

You are probably getting rid of the delegate object after presenting the EFColorPicker (and likely causing a memory leak in your program)

How are you setting the delegate? It is a view controller? Does the program retains it after presenting the color picker?

@KursX
Copy link
Author

KursX commented Mar 4, 2020

func show(controller: SettingsViewController) {
    let navCtrl = UINavigationController(rootViewController: colorSelectionController)
    navCtrl.navigationBar.backgroundColor = UIColor.white
    navCtrl.navigationBar.isTranslucent = false
    navCtrl.modalPresentationStyle = UIModalPresentationStyle.popover
    navCtrl.popoverPresentationController?.delegate = controller
}

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

No branches or pull requests

2 participants