【发布时间】:2016-10-04 18:16:44
【问题描述】:
我通过以下方式添加UISwitch:
let anonSwitch : UISwitch = {
let mySwitch = UISwitch()
mySwitch.on = false
mySwitch.setOn(false, animated: false);
mySwitch.tintColor = UIColor(red: (69/255.0), green: (209/255.0), blue: (153/255.0), alpha: 1.0)
mySwitch.addTarget(self, action: #selector(handleAnonSwitch), forControlEvents: .ValueChanged)
return mySwitch
}()
现在我在mySwitch.addTarget 中的self 关键字上收到以下错误消息:
Cannot convert value of type 'NSObject -> () -> PostFeed' to expected argument type 'AnyObject?'
我在 UIButton 的所有其他 addTarget 函数中使用 self,但我从未遇到此错误
【问题讨论】: