0

While trying to print data using po data it says

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];
}
DomQ
  • 4,184
  • 38
  • 37
Nishanth
  • 33
  • 8
  • Actually the data is returned within the pair of braces `{}` after `else`. If you don't use it at all, you can't see anything. Consider also that `URLSession` works asynchronously. – vadian Nov 27 '16 at 11:50

2 Answers2

0

Are you getting error below in console?

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

I feel you have to configure App Transport Security Exception for "http:" url.

Please look in to the below question to understand adding exception.

Transport security blocked

Update :

The above url gives xml response, refer to below link for xml parsing

xml parsing in ios tutorial

Community
  • 1
  • 1
Dileep
  • 2,399
  • 4
  • 26
  • 39
  • no...not that.. i added in plist. not getting data and response using po it says using "po data" it says error: use of undeclared identifier 'data' error: 1 errors parsing expression – Nishanth Nov 27 '16 at 11:47
  • I tried the above code, and got a XML response. Please parse the xml file using NSXMLParser. – Dileep Nov 27 '16 at 11:56
  • @Nishanth Still getting blank data? – Dileep Nov 27 '16 at 12:00
  • Great it helped you. Please mark this as answer, if it resolved your issue. Happy coding :) – Dileep Nov 27 '16 at 15:04
0

Maybe you could set a breakpoint in the "else" branch.When the data comes back,then it will trigger breakpoint in it, use the "po data".

ZhiyiLiu
  • 9
  • 3