I think this is good because it can help your application get out of time when you try to download some images from the Internet. you can make a new function as follows:
func loadImage(url:String, forImageView: WKInterfaceImage) { // load image let image_url:String = url dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { let url:NSURL = NSURL(string:image_url)! var data:NSData = NSData(contentsOfURL: url)! var placeholder = UIImage(data: data)! // update ui dispatch_async(dispatch_get_main_queue()) { forImageView.setImage(placeholder) } } }
after that, where you want to load the image from urlString, you can use this:
loadImage("http://...", forImageView: self.myImageView)
I hope for this help.
source share