I'm adding a UISwitch
in the following way:
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
}()
Now I'm getting the following error message on the self
keyword in mySwitch.addTarget
:
Cannot convert value of type 'NSObject -> () -> PostFeed' to expected argument type 'AnyObject?'
I use self
in all my other addTarget
functions for UIButton
and I never encounter this error
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…