In the code below I'm confused as to what "self" actually refers to.
let imageURL = URL(string : “http://exampleURLh.jpg”)!
let task=imageDataURLSession.sharedSession().dataTaskWithURL(imageURL, {(data, response, error) in
print (“task finished”)
}
task.resume()
if error == nil {
let downloadedImage = UIImage(data: data!)
self.imageView.image = downloadedImage
}
I know that I'm setting downloadedImage as the imageView using its image property, but I'm not sure why self is needed and what piece of data it holds in this situation. I know it refers to an instance of the viewController class being worked on, but is that instance the UIImage, downloadedImage, or the resource data from the image at the example URL?