From the course: iOS and watchOS App Development: Notifications
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Load an image from the web
From the course: iOS and watchOS App Development: Notifications
Load an image from the web
- While preloading images in the content extension is the fastest, most efficient way to handle images, you will want to load images from elsewhere. That can get a little tricky. Images will load a lot slower than the rest of the code runs timing out. So how do you load them? To show you how, I'm going to simplify this code by using a simple URL string from the web. So go ahead and close off the site at Attributes so you've enough space here, and roll over here to Image URL in the Media, and you will find a URL string of a website that will have a photo for us. I'm going to go and copy this. I hit Download Notification View Controller and find where we got our content, Image View, UI Image named HuliLogo. I'll go and comment that out for now and put a line underneath it, and let's get some more space in here to do some typing. And go ahead and command V, put in that URL string. And what I'm going to do is, first of all, turn this into a URL, unwrapping it with If-Let. So I'm going to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.