String concatenation problem with Swift
I am trying to use string concatenation to generate a url for a network call. However, I am getting intermittent results when trying to concatenate strings.
The attached image shows that it is combined with only "h"
. The relevant code has been added below.
Did I miss something?
Thank.
/* Constants */
private let baseURL = "https://someurl.com/"
private let URLSuffix = "anotherString"
private let typeItem = "item/"
class HITNetworkCoordinator: NSObject {
class var sharedInstance : HITNetworkCoordinator {
return _HITNetworkCoordinatorInstance
}
func downloadItem (itemID: Int) {
let taskURLString = baseURL + typeItem + String(itemID) + URLSuffix
let taskURL = NSURL.URLWithString(taskURLString)
let task = NSURLSession.sharedSession().dataTaskWithURL(taskURL, completionHandler: { (data, response, error) -> Void in
var responseDict : NSDictionary? = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil) as? NSDictionary
println(responseDict)
})
task.resume()
}
+3
source to share