I'm trying to do this simple callback method:
final class MyView: UIView {
var onSomeAction: ((String) -> Void)!
}
final class MyViewController: UIViewController {
let myView = MyView(frame: CGRectZero)
override func viewDidLoad() {
super.viewDidLoad()
myView.onSomeAction = someFunc
}
private func someFunc(str: String) {
}
}
But that's going to create a retain cycle (I believe). I can't just mark the onSomeAction var as weak because that's a compile time error.
Do I really need to go to the level of defining a protocol for this just so I can mark it as a class protocol and then mark that callback to be a weak reference?
I've gotta be missing something here.