/ / NSURLSession retorna dados como nulos no Watch OS2 usando Objective-C - objetivo-c, watchkit, apple-watch, nsurlsession

NSURLSession retorna dados como Null on Watch OS2 usando Objective-C-objective-c, watchkit, apple-watch, nsurlsession

Isso funciona perfeitamente no iPhone (Simlulator e Device), mas no Watch OS2 recebo dados em branco. Qual pode ser o problema com isso?

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];

Respostas:

3 para resposta № 1

Desculpe, encontrei o erro. Tive que adicionar Permite Cargas Arbitrárias na extensão WatchKit. Depois de adicionar, obtive o resultado.


1 para resposta № 2

[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];

}