0
I need to download an image, it is displayed, but after displaying it I need to delete it from the device. But always when I open the app 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
                    })
                }
            }
        })
    }
Please add information on how you download the image and how it is loaded.
– Rafael Leão
At no time in your code the image is being saved on the device. Be sure that this is the code snippet same?
– Paulo Rodrigues
Exactly, why I wanted to know how to delete the image that was being saved temporarily. Below follows the solution as answer I found.
– Gian