Hi. This short code for Kingfisher goes like this
KingfisherManager.shared.retrieveImage(with: ImageResource(downloadURL: URL(string: "URL HERE")!)) { result in
switch result {
case .success(let value):
break
default:
break
}
}
I am actually interested in .success only but if i remove default it will show an error message like Switch must be exhaustive.
How to make this an if statement that goes something like this
if result == .success {
how to get value in scope here so i can use it. thoughts?
}
You can write
if case .success(let value) = result { }
Which is a bit hard to grab at the beginning.
It means and reads: if I can match pattern .success(let value) with success, then…
You can read this old discussion I had with eskimo on this matter: https://developer.apple.com/forums/thread/111213