@@ -22,14 +22,14 @@ class APIController: NSObject {
22
22
func searchItunesFor( searchTerm: String ) {
23
23
24
24
// The iTunes API wants multiple terms separated by + symbols, so replace spaces with + signs
25
- var itunesSearchTerm = searchTerm. stringByReplacingOccurrencesOfString ( " " , withString: " + " , options: NSStringCompareOptions . CaseInsensitiveSearch, range: nil )
25
+ let itunesSearchTerm = searchTerm. stringByReplacingOccurrencesOfString ( " " , withString: " + " , options: NSStringCompareOptions . CaseInsensitiveSearch, range: nil )
26
26
27
27
// Now escape anything else that isn't URL-friendly
28
- var escapedSearchTerm = itunesSearchTerm. stringByAddingPercentEscapesUsingEncoding ( NSUTF8StringEncoding)
29
- var urlPath = " https://itunes.apple.com/search?term= \( escapedSearchTerm) &media=music&entity=album "
30
- var url : NSURL = NSURL ( string: urlPath)
31
- var session = NSURLSession . sharedSession ( )
32
- var task = session. dataTaskWithURL ( url, completionHandler: { data, response, error -> Void in
28
+ let escapedSearchTerm = itunesSearchTerm. stringByAddingPercentEscapesUsingEncoding ( NSUTF8StringEncoding)
29
+ let urlPath = " https://itunes.apple.com/search?term= \( escapedSearchTerm) &media=music&entity=album "
30
+ let url = NSURL ( string: urlPath)
31
+ let session = NSURLSession . sharedSession ( )
32
+ let task = session. dataTaskWithURL ( url, completionHandler: { data, response, error -> Void in
33
33
println ( " Task completed " )
34
34
if ( error) {
35
35
// If there is an error in the web request, print it to the console
@@ -41,7 +41,7 @@ class APIController: NSObject {
41
41
// If there is an error parsing JSON, print it to the console
42
42
println ( " JSON Error \( err!. localizedDescription) " )
43
43
}
44
- var results : NSArray = jsonResult [ " results " ] as NSArray
44
+ var results = jsonResult [ " results " ] as NSArray
45
45
// Now send the JSON result to our delegate object
46
46
self . delegate? . didReceiveAPIResults ( jsonResult)
47
47
} )
0 commit comments