Reputation: 16653
Is it possible to retrieve the value of a POST parameter from a NSURLRequest in the method;
-(BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
Is so, how is this done?
Upvotes: 4
Views: 7297
Reputation: 3739
NSURLRequest *request = ...
NSError *error = nil;
NSDictionary *parameters = [NSJSONSerialization JSONObjectWithData:[request HTTPBody] options:0 error:&error];
Upvotes: 0
Reputation: 6142
That should be possible with the class method of NSURLProtocol:
+ (id)propertyForKey:(NSString *)key inRequest:(NSURLRequest *)request
So if you have got a property named "place" you could try that:
[NSURLProtocol propertyForKey:@"place" inRequest:myRequestObject]
[EDIT]
If you want to retrieve all properties, I think you have to use - (NSData *)HTTPBody
from NSURLRequest
and then parse the property names/values yourself. Should be no problem with urldecode and RegEx.
Upvotes: 3