-
-
Save zats/e297257c6117e68a8a6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parent { | |
var child: Child? { | |
didSet { | |
child.callback = weak(self)?.delegateCallback | |
} | |
} | |
func delegateCallback() { | |
// ... | |
} | |
} | |
class Child { | |
var callback: (Void -> Void)? | |
private func triggerCallback() { | |
callback?() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment