title: Objective-C - 'sendSynchronousRequest:returningResponse:error:' is deprecated: first deprecated in iOS 9.0
body: <pre><code>-(NSArray *)deviceCheck:(NSString *)device
      {
          NSString *deviceRequestString = [NSString stringWithFormat:@"%@?device=%@",webservice,device];
          NSURL *JSONURL = [NSURL URLWithString:deviceRequestString];
          NSURLResponse* response = nil;
          NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:JSONURL];
  
          NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:nil];
          if(data == nil)
              return nil;
          NSError *myError;
          NSArray *tableArray = [[NSArray alloc]initWithArray:[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&amp;myError]];
          return tableArray;
      }
  </code></pre>
  
  <p>but I keep getting this warning:</p>
  
  <pre><code>sendSynchronousRequest:returningResponse:error:' is deprecated: first deprecated in iOS 9.0 - Use [NSURLSession dataTaskWithRequest:completionHandler:] (see NSURLSession.h
  </code></pre>
  
  <p>on this line:</p>
  
  <pre><code>NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:nil];
  </code></pre>
  
  <p>I tried changing to to the following:</p>
  
  <pre><code>NSData* data = [NSURLSession dataTaskWithRequest:request];
  </code></pre>
  
  <p>and</p>
  
  <pre><code>NSData* data = [NSURLSession dataTaskWithRequest:request returningResponse:&amp;response error:nil];
  </code></pre>
  
  <p>both gave me errors saying:</p>
  
  <p>No known class method</p>
  
  <p>PLEASE HELP</p>