Logging HTTPRequest NSUTF8Encoding

41 views Asked by At

When trying to debug a NSURLRequest with POST data I use this to write to my log:

NSLog(@" Body: %@", [[NSString alloc] initWithData:urlRequest.HTTPBody encoding:NSUTF8StringEncoding]);

Which outputs the data like so:

Body: add_contact=%7B%0A%20%20%22ENTITY_DATE%22%20%3A%201484141409.066969%2C%0A%20%20%22ENTITY_PAYLOAD%22%20%3A%20%7B%0A%20%20%20%20%22SYNC_GUID%22%20%3A%20%22B656614A-C79F-4130-93D0-3CE84E4D3EC2-14296-0000380ED36B1B76%22%2C%0A%20%20%20%20%22VDM%22%20%3A%20%22%22%2C%0A%20%20%20%20%22FAX%22%20%3A%20%22%22%2C%0A%20%20%20%20%22LAST_NAME%22%20%3A%2...

How can I clean this string up to make it more readable?

1

There are 1 answers

1
Grifas On

I can tell you an other way to debug. You can use a break point at this line and use the console to debug.

Once the break point stops the execution, in the console, write by example po urlRequest or po urlRequest.debugDescription to see your object.