1


Here is My problem.
I was trying to create programmatically an UIWebView and it worked perfectly, but when I tried to change url from simple NSString to NSString[stringWithFormat] it goes wrong. UIWebView just don't want to load the page, but in Safari(Mac) page load and display content.

My code :

NSString *APP_ID = @"4000";
NSString *PERMISSIONS = @"audio, films, friends";

NSString *full_url = [NSString stringWithFormat:@"http://google.com?a=%@&b=%@", APP_ID, PERMISSIONS];

NSLog(full_url);
NSURLRequest *loginRequest = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:full_url]];

UIWebView *loginWebView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
loginWebView.delegate = self;

[self.view addSubview:loginWebView];
[loginWebView loadRequest:loginRequest];
user1118321
  • 25,567
  • 4
  • 55
  • 86
SJBur
  • 35
  • 3
  • 15

1 Answers1

0

Your formatted URL is will turn out to be "http://google.com?a=4000&b=audio, films, friends". I think you need to URL encode the second parameter to stringWithFormat:. See one answer on how to do that here: Objective-C and Swift URL encoding

Community
  • 1
  • 1
Don
  • 3,654
  • 1
  • 26
  • 47