I have a standard UIButton
in a standard single view project. I want to get the text of the button when it is clicked. However, in Xcode 7.0 GM I am getting strange behavior with the compiler requiring me to use ??
, ?!
, or !!
. When trying to unwrap the text there is more strange behavior: only triple unwrapping finally does it.
@IBAction func buttonTapped(sender: AnyObject) {
print( sender.titleLabel?!.text ) // Optional("Button")
print( sender.titleLabel??.text ) // Optional("Button")
print( sender.titleLabel!!.text ) // Optional("Button")
print( sender.titleLabel?!.text! ) // Optional("Button")
print( sender.titleLabel??.text! ) // Optional("Button")
print( sender.titleLabel!!.text! ) // Button
}
What is going on here?
I have seen
but the sender
is not an array here, and I couldn't see the connection to those answers.