Hi,
I'd like to programmatically tap a navigation bar button, so I wrote some code like this in a view controller:
let b = navigationItem.rightBarButtonItem
if let t = b?.target, let a = b?.action {
print("trying to perform selector")
t.performSelector(a)
}
(I know, normally you should directly call the target, but this is an odd situation. [1])
I get a crash: EXC_BAD_ACCESS. The stack trace in debugger shows:
0 swift_unknownRetain
1 @objc MasterViewController.insertNewObject
2. MasterViewController.viewDidAppear
#1 is the expected method for the selector, but it's body is never executed. What is `unknownRetain`? Is `performSelector` not usable from Swift?
Rob