To show an image from a URL in Swift, follow these steps:
URL
object with the URL of the image you want to load.main.swift77 chars2 lines
URLSession
object to download the image data.main.swift32 chars2 lines
main.swift273 chars11 lines
main.swift18 chars2 lines
UIImageView
with the loaded image.main.swift57 chars4 lines
Putting it all together in a function:
main.swift585 chars21 lines
You can call this function passing a URL string and a UIImageView
to display the loaded image:
main.swift73 chars2 lines
gistlibby LogSnag