Created
July 20, 2014 21:45
-
-
Save armstrongnate/5c5c828f1b82b0315e24 to your computer and use it in GitHub Desktop.
Revisions
-
Nate Armstrong revised this gist
Jul 20, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ config.HTTPAdditionalHeaders = ["Authorization" : authString] let session = NSURLSession(configuration: config) var running = false let url = NSURL(string: "https://example.com/api/v1/records.json") let task = session.dataTaskWithURL(url) { (let data, let response, let error) in if let httpResponse = response as? NSHTTPURLResponse { -
Nate Armstrong created this gist
Jul 20, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ import Foundation let config = NSURLSessionConfiguration.defaultSessionConfiguration() let userPasswordString = "[email protected]:password" let userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding) let base64EncodedCredential = userPasswordData!.base64EncodedStringWithOptions(nil) let authString = "Basic \(base64EncodedCredential)" config.HTTPAdditionalHeaders = ["Authorization" : authString] let session = NSURLSession(configuration: config) var running = false let url = NSURL(string: "https://minutedock.com/api/v1/accounts.json") let task = session.dataTaskWithURL(url) { (let data, let response, let error) in if let httpResponse = response as? NSHTTPURLResponse { let dataString = NSString(data: data, encoding: NSUTF8StringEncoding) println(dataString) } running = false } running = true task.resume() while running { println("waiting...") sleep(1) }