title: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
body: <p>I am facing the Problem when I have updated my Xcode to 7.0 or iOS 9.0.
  Somehow it started giving me the Titled error</p>
  
  <blockquote>
    <p>"The resource could not be loaded because the App Transport Security
    policy requires the use of a secure connection"</p>
  </blockquote>
  
  <p>Webservice Method:</p>
  
  <pre><code>-(void)ServiceCall:(NSString*)ServiceName :(NSString *)DataString
  {
  NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
      [sessionConfiguration setAllowsCellularAccess:YES];
      [sessionConfiguration setHTTPAdditionalHeaders:@{ @"Accept" : @"application/json" }];
      NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];
  
      NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",ServiceURL]];
      NSLog(@"URl %@%@",url,DataString);
      // Configure the Request
      NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
      [request setValue:[NSString stringWithFormat:@"%@=%@", strSessName, strSessVal] forHTTPHeaderField:@"Cookie"];
      request.HTTPBody = [DataString dataUsingEncoding:NSUTF8StringEncoding];
      request.HTTPMethod = @"Post";
  
      // post the request and handle response
      NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
                                            {
                                                // Handle the Response
                                                if(error)
                                                {
                                                    NSLog(@"%@",[NSString stringWithFormat:@"Connection failed: %@", [error description]]);
  
                                                    // Update the View
                                                    dispatch_async(dispatch_get_main_queue(), ^{
  
                                                        // Hide the Loader
                                                        [MBProgressHUD hideHUDForView:[[UIApplication sharedApplication] delegate].window animated:YES];
  
  
                                                    });
                                                    return;
                                                }
                                                NSArray * cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:request.URL];
                                                for (NSHTTPCookie * cookie in cookies)
                                                {
                                                    NSLog(@"%@=%@", cookie.name, cookie.value);
                                                    strSessName=cookie.name;
                                                    strSessVal=cookie.value;
  
                                                }
  
                                                NSString *retVal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  }];
  [postDataTask resume];
  
  }
  </code></pre>
  
  <p>The service is Running fine for Xcode earlier versions and iOS previous versions But when I have updated to Xcode 7.0 that is on iOS 9.0, it started to give me the Problem like following when I am calling the above web service method. The Logged Error which I am getting is:</p>
  
  <blockquote>
    <p>Connection failed: Error Domain=NSURLErrorDomain Code=-1022 "The
    resource could not be loaded because the App Transport Security policy
    requires the use of a secure connection."
    UserInfo={NSUnderlyingError=0x7fada0f31880 {Error
    Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"},
    NSErrorFailingURLStringKey=<strong>MyServiceURL</strong>,
    NSErrorFailingURLKey=<strong>MyServiceURL</strong>,
    NSLocalizedDescription=The resource could not be loaded because the
    App Transport Security policy requires the use of a secure
    connection.}</p>
  </blockquote>
  
  <p>I have tried Following Questions and answers but did not get any result there, is there any advance idea how I can remove that service call error?</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/32069393/the-resource-could-not-be-loaded-is-ios9">The resource could not be loaded is ios9</a></li>
  <li><a href="https://stackoverflow.com/q/32427300">App Transport Security Xcode 7 beta 6</a></li>
  <li><a href="https://stackoverflow.com/a/32609970">https://stackoverflow.com/a/32609970</a></li>
  </ol>