3

This works perfectly on iPhone (Simlulator and Device) but on Watch OS2 i get blank data. What might be the issue with this ?

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:theRequest
                                        completionHandler:
         ^(NSData *data, NSURLResponse *response, NSError *error) 
 {
      theData = [[NSString alloc]initWithBytes:[data bytes] length:[data length] encoding:NSUTF8StringEncoding];
    NSLog(@"%@", theData);
}];
 [task resume];
Karthik
  • 103
  • 7

2 Answers2

3

Sorry found the mistake. Had to add Allows Arbitrary Loads on the WatchKit extension. After adding i got the result.

Karthik
  • 103
  • 7
  • 1
    Are we need to add allows arbitrary in both app and extension? even after adding in extension i couldn't get any response – Anamika Nov 13 '15 at 15:34
  • http://useyourloaf.com/blog/app-transport-security/#enabling-exceptions-to-app-transport-security there is an explanation on how to enable Arbitrary load. You need "to globally disable App Transport Security. In the App Info.plist file add the dictionary key NSAppTransportSecurity with a boolean key NSAllowsArbitraryLoads set to YES" – Karsten Jan 17 '17 at 17:34
1

[self.table setNumberOfRows:[arrurlimg1 count ]withRowType:@"QuoteTableRow"];

for (NSInteger i = 0; i < self.table.numberOfRows; i++) {

    ICBQuoteTableRow* theRow = [self.table rowControllerAtIndex:i];

    NSURLSessionConfiguration  *config =[NSURLSessionConfiguration defaultSessionConfiguration];
    NSURLSession *session =[NSURLSession sessionWithConfiguration:config];

    NSURLSessionTask *task = [session dataTaskWithURL:url completionHandler:^(NSData * _Nullable data1, NSURLResponse * _Nullable response, NSError * _Nullable error)
                              {
                                  for (int i=0; i<arrurlimg1.count; i++)
                                  {

                                      UIImage *image =imgData1;
                                      [theRow.myFirstImage setImage:image];
                                      // [theRow.myGroup setBackgroundImage:image];
                                  }
                              }];
    [task resume];

}