Mr E Mr E - 2 years ago 169
Swift Question

How to concatenate strings in Swift

I am trying to get USERNAME and PASSWORD from the user and put them inside of a string.

var id = "1"
var pw = "password"

Here is my code:

parser = NSXMLParser(contentsOfURL: NSURL(string : "")!)!

But it creates this result:


How do I put the values of
inside of a string?

Answer Source

To Concat strings in swift you have two options:

let completeURL = "\(usernameVar)&\(passwordVar)"

let completeURL = "" + usernameVar + "&" + passwordVar
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download