title: Not sure where in code to place storageRef.downloadURL
body: <p>After updating Firebase to Version 4 and correcting all 200 errors, I am left with 2 warnings which make my app crash.  I looked up this error and tried the resolution with no success:</p>
  
  <pre><code>storageReference.downloadURLWithCompletion()
  </code></pre>
  
  <p>I must be doing it wrong:</p>
  
  <pre><code>func setUserInfo(_ user: User!, usersname: String, email: String, password: String, cell: String, data: Data!) {
  
      // Create Path for User Image
      let imagePath = "images/riders/\(user.uid)/Profile Pic/userPic.jpg"
  
      // Create image Reference
      let imageRef = rDataService.Instance.storageRef.child(imagePath)
  
      // Create Metadata for the image
      let metaData = StorageMetadata()
      metaData.contentType = "image/jpeg"
  
      // Save the user Image in the Firebase Storage File
      imageRef.putData(data as Data, metadata: metaData) { (metaData, error) in
          if error == nil {
              let changeRequest = user.createProfileChangeRequest()
              changeRequest.displayName = usersname
              changeRequest.photoURL = metaData?.downloadURL()
              changeRequest.commitChanges(completion: { (error) in
  
                  if error == nil {
                      self.saveUser(user, usersname: usersname, email: email, password: password, cell: cell)
  
                  } else {
                      print(error!.localizedDescription)
                  }
              })
  
          } else {
              print(error!.localizedDescription)
          }
      }
  
  }
  </code></pre>
  
  <p>The error is happening on this line: </p>
  
  <pre><code>changeRequest.photoURL = metaData?.downloadURL()
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>After adjustments, getting warning on this line:</p>
  
  <pre><code>if let profilepicMetaData = profilepicMetaData {
  
  error: Value 'profilepicMetaData' was defined but never used; consider  replacing with boolean test
  </code></pre>
  
  <p>App is still crashing:</p>
  
  <pre><code>// Save the user profile Image in the Firebase Storage File
      imageRef.putData(data as Data, metadata: profilepicMetaData) { (profilepicMetaData, error) in
          if let profilepicMetaData = profilepicMetaData {
              imageRef.downloadURL(completion: { (url, error) in
  
                  guard let url = url else {
                      if let error = error {
                          print(error)
                      }
                      return
                  }
                  let changeRequest = user.createProfileChangeRequest()
                  changeRequest.displayName = usersname
                  changeRequest.photoURL = url
  
                  changeRequest.commitChanges(completion: { (error) in
  
                  if error == nil {
                      self.saveUser(user, usersname: usersname, email: email, password: password, year: year, makeAndModel: makeAndModel, cell: cell, plateNo: plateNo)
  
                  } else {
                      print(error!.localizedDescription)
                  }
              })
          })
  
          } else {
              print(error!.localizedDescription)
          }
      }
  </code></pre>
  
  <p>Crash!</p>
  
  <p><a href="https://i.stack.imgur.com/nx2wz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nx2wz.png" alt="crash screen shot"></a></p>