title: Using SdWebImage and Image Change immediately by swift
body: <p><a href="https://youtu.be/-gCj_KVbIjI" rel="nofollow noreferrer">This is Question Video</a></p>
  
  <p>I have a problem about imageView by using SDWebImage.<br>
  I change user's image and already get new user's image url, but when I push to this ViewController, it will show the old image first and change to new image.<br>
  What's wrong with me?
  Thanks.<br></p>
  
  <pre><code>var avatar:String = "" // previous VC data pass to here 
  
  var photoImageView:UIImageView = { () -&gt; UIImageView in
      let ui = GeneratorImageView()
      ui.backgroundColor = UIColor.clear
      ui.layer.masksToBounds = true 
      ui.contentMode = .scaleAspectFill
      return ui
  }()
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      iconImageFromUrl(imageView: iconImageView, url: avatar, isResize: false)
  }    
  
  
  func iconImageFromUrl(imageView:UIImageView, url:String,isResize:Bool) {
  
  imageView.setShowActivityIndicator(true)
  imageView.setIndicatorStyle(.gray)
  
  imageView.sd_setImage(with: URL(string:url), placeholderImage: nil, options: .lowPriority, progress: nil
      , completed: { (image, error, cacheType, url) in
  
          guard image != nil else{
              imageView.image = resizeImage(image: #imageLiteral(resourceName: "defaultIcon"), newWidth: 50)
              return
          }
  
          DispatchQueue.global().async {
              let data = try? Data(contentsOf: url!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
  
              if data != nil
              {
                  if let image = UIImage(data: data!)
                  {
                      DispatchQueue.main.async {
  
                          if isResize == true{
                              imageView.image = resizeImage(image: image, newWidth: 250)
                          }else{
                              imageView.image = image
                          }
                      }
                  }
              }
          }
  })
  }
  </code></pre>