-(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:&response error:nil];
if(data == nil)
return nil;
NSError *myError;
NSArray *tableArray = [[NSArray alloc]initWithArray:[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&myError]];
return tableArray;
}
但我一直收到这个警告:
sendSynchronousRequest:returningResponse:error:' is deprecated: first deprecated in iOS 9.0 - Use [NSURLSession dataTaskWithRequest:completionHandler:] (see NSURLSession.h
在这一行上:
NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
我尝试将其更改为以下内容:
NSData* data = [NSURLSession dataTaskWithRequest:request];
并且
NSData* data = [NSURLSession dataTaskWithRequest:request returningResponse:&response error:nil];
两者都给我报错,提示:
未知的类方法
请帮忙解决
NSLog(@"Here"); }else{ NSLog(@"Here 2"); } }];` 但是没有起作用。
- Magna Boss