strange UIImageview load

Hi Apple Developer,


have some strange behavior with load simple JPG images from my Server...


It works but:

Start my App,load all pictutes it works...

delete random file on my Server reload all urls this and the renamed or deleted image

is already load done...


my http response is 200 too but file is deleted or renamed

my browser call the same URL and response is not found thats OK.


have restart my App : same procedure

clean my App: same Procedure


reinstall :load all pictures and rename or delete it works (but is my picture renamed or delete) old picture is load,

nut only 1times


rename my picture on my Server reload my App the last picture is loaded again successful.


Have no idea.


macOS: last Update

Xcode : 8.0 Final and 8.1b2 too



here my code from my class


swift and Xcode make me crazy....



extension myObjClass {


func downloadedImage() {

let strurl = localDev.picPath! + self.ArtID

let url = URL(string: strurl)

UIApplication.shared.isNetworkActivityIndicatorVisible = true

URLSession.shared.dataTask(with: url!, completionHandler: { (data, response, error) -> Void in

let resp = response as? HTTPURLResponse

// the url to my picture is 100% delete but response is 200 and picture is the last one after successful load

if(resp?.statusCode == 200) {

let image = UIImage(data: data!)

print("set Image Data")

self.picture = image

self.isPictureSet = true

let name = Notification.Name("reloadIsDone")

NotificationCenter.default.post(name: name, object: nil)

}

else{

print("picture not found")

self.picture = UIImage(named: "noPic.JPG")

self.isPictureSet = false

let name = Notification.Name("reloadIsDone")

}

}

).resume()

UIApplication.shared.isNetworkActivityIndicatorVisible = false

}



}

Replies

hi,


found this with request instead url and it works



let request = URLRequest(url: url!, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: 10)

UIApplication.shared.isNetworkActivityIndicatorVisible = true

URLSession.shared.dataTask(with: request, completionHandler: { (data, response, error) -> Void in


.....

}

I think you spotted the problem yourself: it is a cache issue.


In the new request you force to reload cahce data, hence the file that have been deleted are no more accessible.


Otherwise you load them from your cache.