Created
June 3, 2014 23:21
-
-
Save Nub/d39cb2f3ec235ce4eb66 to your computer and use it in GitHub Desktop.
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 characters
| func fetch(method: String, body: (NSString, NSData)!, completion: (NSData -> Void)) { | |
| let request = self.request() | |
| request.HTTPMethod = method | |
| if body != nil { | |
| let mime = body.0 | |
| let data = body.1 | |
| request.setValue(mime, forHTTPHeaderField: Networking.mimeHTTPHeaderField) | |
| request.HTTPBody = data; | |
| } | |
| NSURLConnection.sendAsynchronousRequest(request, queue: Networking.operationQueue){(response: NSURLResponse!, data: NSData!, error: NSError!) in | |
| completion(data) | |
| } | |
| } | |
| func GET(completion: (NSData -> Void)) { | |
| fetch("GET", body: nil, completion:completion) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment