I have a situation in which i am using POST method to host a url in safari browser in simulator. The web page is opened in safari after launching my iOS app in simulator. To launch safari i have used [[UIApplication sharedApplication] openURL: ...
The post method is as follows:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://***some client url***.jsp"]];
NSString *post = [NSString stringWithFormat:@"username=%@&password=%@", userName, password];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
[request setHTTPMethod:@"POST"];
[request setValue:[NSString stringWithFormat:@"%d", [postData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:postData];`
NSURLConnection* _urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[_urlConnection start];
this piece of code works fine when using UIWebView. But i want to launch Safari using this "request" which has appended username & password data from the POST method.
To launch Safari i must call this code:
[[UIApplication sharedApplication] openURL:request];
But this throws a warning obviously because "request" is of type NSMutableURLRequest. "Semantic Issue: Incompatible pointer types sending 'NSMutableURLRequest *' to parameter of type 'NSURL *" ..
I cannot even use [[UIApplication sharedApplication] openURL:request.URL];
since this will give me the URL which is not appended with username & password(with out POST method).
I want to know how to typecast/convert this request(NSMutableURLRequest) so that i can accommodate it in the [[UIApplication sharedApplication] openURL ....
Hope i am quite clear with my question. Any help will be highly appreciated. Thanks in advance !!