沒有得到數據,而嘗試使用po data
它說從Web服務
error: use of undeclared identifier 'data'
error: 1 errors parsing expression
-(void)viewWillAppear:(BOOL)animated {
NSMutableURLRequest*req=[[NSMutableURLRequest alloc]init];
NSURL*url=[NSURL URLWithString:@"http://www.thomas-bayer.com/sqlrest/CUSTOMER/"];
[req setURL:url];
[[[NSURLSession sharedSession]dataTaskWithRequest:req completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if(error){
NSLog(@"error");
}else{}
}] resume];
}
實際上,數據是在'else'之後的大括號'{}'中返回的。如果你根本不使用它,你什麼都看不到。還要考慮到'URLSession'異步工作。 – vadian