<分区>
从 Swift 2.2 开始,以下代码会发出警告:
No method declared with Objective-C selector'sync'
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