Apple Watch Kit wouldn't fetch Image

468 views Asked by At

Apple Watch Kit wouldn't fetch image from URL

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSLog(@"URL string for image %@",urlStr);
        NSData *imgData = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlStr]];
        });

The fetch did work in Watch Simulator, But when I run it with a watch, I get these error as log

2016-12-19 15:21:47.491560 Test app WatchKit App Extension[250:130169] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1 2016-12-19 15:21:48.497360 Test app WatchKit App Extension[250:130169] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2 2016-12-19 15:21:49.499671 Test app WatchKit App Extension[250:130169] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3 2016-12-19 15:21:50.501699 Test app WatchKit App Extension[250:130169] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:7 Err:-1 Errno:1 Operation not permitted 2016-12-19 15:21:50.502103 Test app WatchKit App Extension[250:130169] [] nw_resolver_create_dns_service_on_queue DNSServiceCreateConnection failed: ServiceNotRunning(-65563)

1

There are 1 answers

0
Kit On BEST ANSWER

You cannot use the NSDataWithContentsOfURL for image downloading. It will not work anymore in real watch os device. You may use URLSession or other third party library such as Kingfisher.