2

I find myself doing this quite a bit in my app:

myLabel.text = "My name is \(peopleDictionary["Name"])"

Which throws an error because of the double quotes around name. I am constantly having to do this:

let name = peopleDictionary["Name"]
myLabel.text = "My name is \(name)"

Am I missing a very easy way to get this to work inline?

Edit: a work around that doesn't require an extra line of code would be

myLabel.text = "My name is " + peopleDictionary["Name"]
Travis M.
  • 10,930
  • 1
  • 56
  • 72
  • 2
    No, that's exactly how to do it. Compare [escape dictionary key double quotes when doing println dictionary item in Swift](http://stackoverflow.com/questions/24024754/escape-dictionary-key-double-quotes-when-doing-println-dictionary-item-in-swift). – Martin R Feb 24 '15 at 22:43
  • Sorry for the duplicate, I searched for quite a while but never saw that one. It's difficult getting the exact terminology. – Travis M. Feb 24 '15 at 22:46

0 Answers0