I upload pictures from the server through this method:
func imgfromlink(link url: String) -> UIImage? { if let iurl = NSURL(string: url) { if let idata = NSData(contentsOfURL: iurl) { if let image = UIImage(data: idata){ return image } } } return nil } The essence is this: in the method I pass a link to the picture, and at the output I get a UIImage. But I have a little problem. If the image on the server is updated (the URL of the image remains the same), and I try to download this image again through this method, then it is not updated.
I thought it was probably caching and tried to pick NSData and found the following options: .DataReadingUncached key there options: .DataReadingUncached
I redid my method:
func imgfromlinkUncached(link url: String) -> UIImage? { if let iurl = NSURL(string: url) { do { let idata = try NSData(contentsOfURL: iurl, options: .DataReadingUncached) if let image = UIImage(data: idata){ return image } } catch _ { return nil } } return nil } But nothing has changed. Pictures are not updated. And for me this is critical, since the user should be able to change the avatar and everywhere should be displayed the updated version of the avatar, but the url of the avatar remains unchanged, only the picture on the server changes.
Xcode version 8.0
NSDataReadingUncachedshould work. There is one more approach - to add to urla "? Random =" + random number - markov