@@ -67,13 +67,13 @@ class GovDataRequest {
6767 }
6868 case " http://go.usa.gov " :
6969 // go.usa.gov requires that the apiKey be the 2nd argument
70- if countElements ( queryString) == 0 {
70+ if count ( queryString) == 0 {
7171 queryString += " ? " + argKey + " = " + argValue + " &apiKey= " + APIKey
7272 } else {
7373 queryString += " & " + argKey + " = " + argValue
7474 }
7575 default :
76- if countElements ( queryString) == 0 {
76+ if count ( queryString) == 0 {
7777 queryString += " ? " + argKey + " = " + argValue
7878 } else {
7979 queryString += " & " + argKey + " = " + argValue
@@ -83,13 +83,13 @@ class GovDataRequest {
8383 }
8484
8585 //If there are arguments, append them to the url
86- if countElements ( queryString) > 0 {
86+ if count ( queryString) > 0 {
8787 url += queryString
8888 }
8989
9090 //DOT FMCSA requires that the key be placed at the end.
9191 if APIHost == " https://mobile.fmcsa.dot.gov " {
92- if countElements ( queryString) > 0 {
92+ if count ( queryString) > 0 {
9393 url += " &webKey= " + APIKey
9494 } else {
9595 url += " ?webKey= " + APIKey
@@ -101,7 +101,7 @@ class GovDataRequest {
101101 // Send the request to the API and parse
102102 var urlToPackage = url. stringByAddingPercentEscapesUsingEncoding ( NSUTF8StringEncoding)
103103 println ( urlToPackage)
104- var urlToSend : NSURL = NSURL ( string: urlToPackage!)
104+ var urlToSend : NSURL = NSURL ( string: urlToPackage!) !
105105 var apiSessionConfiguration : NSURLSessionConfiguration = NSURLSessionConfiguration . defaultSessionConfiguration ( )
106106 apiSessionConfiguration. timeoutIntervalForRequest = timeOut
107107 var session = NSURLSession ( configuration: apiSessionConfiguration)
@@ -117,7 +117,7 @@ class GovDataRequest {
117117 }
118118 var err : NSError ?
119119 if self . responseFormat == " JSON " {
120- var jsonResult = NSJSONSerialization . JSONObjectWithData ( data, options: NSJSONReadingOptions . MutableContainers, error: & err) as NSDictionary
120+ var jsonResult = NSJSONSerialization . JSONObjectWithData ( data, options: NSJSONReadingOptions . MutableContainers, error: & err) as! NSDictionary
121121 if ( err != nil ) {
122122 // If there is an error parson JSON, print it to the console
123123 NSLog ( " Error parsing the JSON " )
@@ -126,7 +126,7 @@ class GovDataRequest {
126126 } else if self . responseFormat == " XML " {
127127 //let parser = SWXMLHash()
128128 var dataString = NSString ( data: data, encoding: NSUTF8StringEncoding)
129- let xml = SWXMLHash . parse ( dataString )
129+ let xml = SWXMLHash . parse ( data )
130130 self . delegate? . didCompleteWithXML ( xml)
131131 }
132132 } )
0 commit comments