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 linesURLSession object to download the image data.main.swift32 chars2 linesmain.swift273 chars11 linesmain.swift18 chars2 lines
UIImageView with the loaded image.main.swift57 chars4 linesPutting it all together in a function:
main.swift585 chars21 linesYou can call this function passing a URL string and a UIImageView to display the loaded image:
main.swift73 chars2 lines
gistlibby LogSnag