I am working in a UIWebView ios app.
in the delegate method:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
I get the body as follow:
NSString *stringPost = [[NSString alloc] initWithData:request.HTTPBody encoding:NSASCIIStringEncoding];
It works ok, but now, i would like to add a parameter to the body and I try it as follow:
NSMutableData *myBody = [NSMutableData dataWithData:request.HTTPBody];
[myBody appendData: [[NSString stringWithFormat: @"isNative", @"TRUE"] dataUsingEncoding: NSUTF8StringEncoding]];
[request setHTTPBody:myBody];
it not works.
Any idea of how to add parameters to my httpBody?
Thank you
When you specify format for string then you are in need of indicate which format would be used (like %@
, %d
, %.2f
e.g.). I'm not sure what you want to specify, but you need to use stringWithFormat
somethig like this
[myBody appendData: [[NSString stringWithFormat: @"isNative = %@", @"TRUE"] dataUsingEncoding: NSUTF8StringEncoding]];