URL Image for Apple Watch

I am trying to use this solution: load-image-from-url-on-watchkit

I have a table on the clock in which I try to load images in each row. I run this code and then update the text fields of the table. Without trying to get images, all text loads correctly.

But when I add this code:

    let site = "myurl.com/image.jpeg"    //I have copied this and it is an image
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
                let url:NSURL = NSURL(string:site)!
                var data:NSData = NSData(contentsOfURL: url)!
                var placeholder = UIImage(data: data)!

                dispatch_async(dispatch_get_main_queue()) {
                    row.myRowImage.setImage(placeholder)
                }
            }

I get the error: fatal error: zero unexpectedly found while deploying optional value

And I can’t understand what can cause this if it is loaded correctly and other parts of the table are loaded correctly. Any help is much appreciated!

+4
source share
2 answers

URL URL, RFC 2396. , http:// ftp .. URL.

+2

plist . , .

URL- http:// https://, .

+3

Source: https://habr.com/ru/post/1598983/


All Articles