从 Swift 2.2 开始,以下代码给出警告:
没有使用 Objective-C 选择器“同步”声明的方法
if let tabBarController = segue.destinationViewController as? TabBarController {
tabBarController.navigationItem.rightBarButtonItem =
UIBarButtonItem(title: "Upload",
style: .Plain,
target: tabBarController,
action: "sync")
我应该用什么替换action: "sync"
它以消除警告?
我试过了:
Selector("sync") // The Xcode provided fix which yields the same warning
#selector(tabBarController.sync()) // Error: Argument of '#selector' does not refer to initializer or method
Selector(tabBarController.sync()) // No error/warning but doesn't fire sync function