Joseph Astrahan
Joseph Astrahan

Reputation: 9072

Swift 2 to 3 Migration Error Regarding String Concatenation

I have the following code below.

let url = "http://websitehere.com/restapi/v1/userlogin?email="+username+"&password="+password+"&deviceid="+deviceid

For some reason the compiler won't take it. Gives me the following error below.

Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions

Why won't the old swift2 code work anymore, what is it even talking about here? If it is too complex, how would I fix it and why is it to complex?

Upvotes: 1

Views: 49

Answers (1)

matsoftware
matsoftware

Reputation: 766

I would always use this format:

let url = "http://websitehere.com/restapi/v1/userlogin?email=\(username)&password=\(password)&deviceid=\(deviceid)"

Upvotes: 2

Related Questions