0

I am getting this error:

Expression was too complex to be resolved in reasonable time

Please help me out. What should I do? I am using the same line in the previous view controller and it's working perfectly.

let url = URL(string: self.con+"loc?email="+email+"&lat="+lati+"&log="+logi!)
rmaddy
  • 314,917
  • 42
  • 532
  • 579

2 Answers2

0

Break it down to smaller expressions. Swift compiler is too dumb to understand your expression ))

Like this:

let paramsStr = "loc?email=" + email + "&lat=" + lati + "&log=" + logi let url = URL(string: self.con + paramsStr)

Fahri Azimov
  • 11,470
  • 2
  • 21
  • 29
0

The reason behind this error is that Xcode gets confused when you use too many + signs. Always try to use the String Interpolation:

let paramsStr = "loc?email=\(email)&lat=\(lati)&log=\(logi)"

Also a good read about this topic: https://stackoverflow.com/a/29931329/3403364

Community
  • 1
  • 1
Rufat Mirza
  • 1,425
  • 14
  • 20