title: iOS Swift: Could not cast value type '__NSCFNumber' to 'NSString'
body: <p>I am retrieving a number value from my Firebase database (JSON db) and then displaying this number into a <code>textField</code>, although I get this error when I try to display it.</p>
  
  <blockquote>
    <p>Could not cast value type '__NSCFNumber' to 'NSString'</p>
  </blockquote>
  
  <p>How can I properly convert the retrieved value to a String, taking into consideration that this value maybe change between a String and a Number when I retrieve it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>let quantity = child.childSnapshot(forPath: "quantity").value // Get value from Firebase
  
  // Check if the quantity exists, then add to object as string.
  if (!(quantity is NSNull) &amp;&amp; ((quantity as! String) != "")) {
      newDetail.setQuantity(quantity: quantity as! String)
  }
  </code></pre>