如何在Swift语言中将动态值附加到GET URL?

时间:2015-11-07 09:09:32

标签: ios iphone swift2 xcode7 nsurl

我对Swift很新,我有一个简单的问题

我以下列方式发送GET请求

loader!.getDataFromRequest(request: NSURLRequest(URL: NSURL(string: "http://......../GetAreaOfOperation?lastCityID=0&batchSize=200")!), dataIndex: -1)

现在我要发送

lastCityID = city   // city is an integer which is dynamic   
// instead of lastCityID = 0

请帮帮我。

1 个答案:

答案 0 :(得分:0)

lastCityID = city
loader!.getDataFromRequest(request: NSURLRequest(URL: NSURL(string: "http://......../GetAreaOfOperation?lastCityID=\(lastCityID)&batchSize=200")!), dataIndex: -1)