简体   繁体   中英

Apple Watch Kit wouldn't fetch Image

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM