var hello = "sad"
var u = "\(hello)"
println(u) // it prints sad
@IBOutlet weak var myTextField: UITextField!
func textFieldShouldReturn(textField: UITextField) -> Bool {
println(myTextField.text)
}
To the text field i pass "\(hello)", but i don't see the value in the log.
short answer, no.
long answer, the (hello) is evaluated at compile time, and hence wont work at run time through a text field.
No, this will of course not work. And it would be a serious security issue if it would.
At compile time the compiler detects those \() and compiles these strings to use string interpolation in the assembly/machine code. You can think of this as if the compiler would turn "Hello \(name)" into "Hello " + name.
At runtime these strings are just collections of characters for whose content nobody cares.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With