I need to download an image, it is displayed, however after displaying it I need to delete it from the device. But whenever I open the application again it is already loaded.
func getPhoto(pathPhoto: String, imageview: UIImageView) {
activityIndicator = UIActivityIndicatorView(frame: CGRectMake(20, 20, imageview.frame.size.width - 40, imageview.frame.size.height - 40))
activityIndicator.color = UIColor(red: 64.0/255.0, green: 109.0/255.0, blue: 157.0/255.0, alpha: 1.0)
activityIndicator.startAnimating()
imageview.addSubview(activityIndicator)
var photoUrlString = urlImages
photoUrlString += pathPhoto
var imgURL: NSURL = NSURL(string: photoUrlString)!
let request: NSURLRequest = NSURLRequest(URL: imgURL)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: {(response: NSURLResponse!,data: NSData!,error: NSError!) -> Void in
if error == nil {
if data == nil {
NSLog("Erro ao baixar")
} else {
self.image = UIImage(data: data)
dispatch_async(dispatch_get_main_queue(), {
self.activityIndicator.stopAnimating()
self.activityIndicator.removeFromSuperview()
imageview.image = self.image
})
}
}
})
}