Skip to content

Instantly share code, notes, and snippets.

@juliengdt
Created September 1, 2016 09:24
Show Gist options
  • Save juliengdt/c72b064a57e13f0bb89e2f6141d08ecb to your computer and use it in GitHub Desktop.
Save juliengdt/c72b064a57e13f0bb89e2f6141d08ecb to your computer and use it in GitHub Desktop.
Pretty print extension for Alamofire Request
extension Alamofire.Request {
func responseDebugPrint() -> Self {
return responseJSON() {
response in
if let JSON: AnyObject = response.result.value,
JSONData = try? NSJSONSerialization.dataWithJSONObject(JSON, options: .PrettyPrinted),
prettyString = NSString(data: JSONData, encoding: NSUTF8StringEncoding) {
print(prettyString)
} else if let error = response.result.error {
print("Error Debug Print: \(error.localizedDescription)")
}
}
}
}
@aliwaseem72
Copy link

@smaljaar How to use it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment