title: How to use different User-Agent in different iOS Webview request
body: <p>I know I can use the below code to change the default agent:</p>
  
  <pre><code>NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"Your user agent", @"UserAgent", nil];
  [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
  </code></pre>
  
  <p>but I want to request a different User-Agent for different requests. Examples: request 'www.google.com', use agent=‘google Agent’, request 'www.github.com', use agent='github Agent'.</p>
  
  <p>I have tried the below way to set the 'User_Agent' in each request, but it doesn't seem to work.</p>
  
  <pre><code>- (void)viewDidLoad {
      NSString *urlAddress = @"http://www.amazon.com";
  
      //Create a URL object.
      NSURL *url = [NSURL URLWithString:urlAddress];
  
      //URL Requst Object
      NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:url];
      [requestObj setValue:@"Foobar/1.0" forHTTPHeaderField:@"User_Agent"];
  
      // But the value is not "Foobar/1.0"
      NSString* secretAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]; 
      NSLog(@"agent - %@", secretAgent); 
  
      //Load the request in the UIWebView.
      [webView loadRequest:requestObj];
  }
  </code></pre>
  
  <p>One more question:</p>
  
  <p>It seems a change to the default agent only work change in 'AppDelegate' or 'initialize'. Am I right? Because I try to change in 'viewDidLoad' but it doesn't seem to work.</p>