Skip to content

Instantly share code, notes, and snippets.

@ivangodfather
Created September 15, 2015 07:36
Show Gist options
  • Save ivangodfather/9f3ad527198ee513308e to your computer and use it in GitHub Desktop.
Save ivangodfather/9f3ad527198ee513308e to your computer and use it in GitHub Desktop.
request(.GET, CUSTOMER_URL, parameters: params, encoding: .URL).responseJSON { (request, response, result) -> Void in
var message = JSON(result.value ?? "")["message"].string ?? "Default value to make it nonOptional"
switch(result) {
case .Success(let json):
if let customer = JSON(json)["customer"].dictionaryObject {
GlobalCache.sharedInstance.setCustomer(customer)
}
completion(succeed: response?.statusCode == 200, message: message) //ERROR
case .Failure(_,_):
completion(succeed: false, message: message) //ERROR
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment