Created
August 12, 2016 06:08
-
-
Save feighter09/2b8f8bd6331de62e54761a135f2903fd to your computer and use it in GitHub Desktop.
This file contains 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
import Alamofire | |
import SwiftyJSON | |
protocol NetworkClientType { | |
func makeRequest(url: String, | |
params: [String : AnyObject], | |
callback: (JSON?, ErrorType?) -> Void) | |
} | |
struct NetworkClient: NetworkClientType { | |
func makeRequest(url: String, | |
params: [String : AnyObject], | |
callback: (JSON?, ErrorType?) -> Void) | |
{ | |
request(.POST, url, parameters: params).response { _, _, data, error in | |
if let jsonData = data where error == nil { | |
let json = JSON(data: jsonData) | |
callback(json, nil) | |
} | |
else { | |
callback(nil, error) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment