Adding an Xcode Breakpoint to Register the NSData Returned for NSRequest

I found the breakpoint very convenient for getting rid of all NSLog instructions through all my code. This time I'm looking for a way to print an html response coming from NSRequest at a breakpoint.

Assuming returnData is a variable returned from my NSRequest, I tried to add a breakpoint with a debugger command as follows:

po (@ "% @", returnData)

but he gives me the whole HEX answer

Then i tried with this

po ([[NSString alloc] initWithData: returnData encoding: NSUTF8StringEncoding])

but I get an error: using undeclared identifier 'NSUTF8StringEncoding'

+4
source share
2 answers

NSUTF8StringEncoding is NSUInteger, in NSString.h you can see that the value is 4, so you can do it

po [[NSString alloc] initWithData:returnData encoding:4] 
+9
source

NSUTF8StringEncoding is an enumeration declared in NSString.h that is declared in the base structure. Have you double checked that the base structure was imported into the project? if so, try importing NSString.h and recompiling.

On the other hand, I type nsdata as follows

  NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(@"Response:%@",responseString); 
-1
source

Source: https://habr.com/ru/post/1483317/


All Articles