I want to display the data from this URL:
http://www.football-data.org/soccerseasons/351/fixtures?timeFrame=n14
My baseURL is let baseUrl = NSURL(string: "http://www.football-data.org")!
,
so my request is let request = NSMutableURLRequest(URL: baseUrl.URLByAppendingPathComponent("soccerseasons/" + "\(league.id)" + "/fixtures?timeFrame=n14"))
But the ?timeFrame=n14
doesn't work.
Anyone knows how to solve this so I can display that data?
The problem is that the question mark in
?timeFrame=n14
is treated as part of the URL's path and therefore HTML-escaped as%3F
. This should work:Alternatively, use
NSURLComponents
, which lets you build an URL successively from individual components (error checking omitted for brevity):Update for Swift 3: