title: How to convert Base64 string to NSData?
body: <p>I have an iOS application (written in Swift) that retrieves data from a wcf service in JSON format. One of the data is an image stored as a <strong>base64string</strong>. However, I was not able to convert the <strong>base64string</strong> to <strong>NSData</strong>.</p>
  
  <p>My main purpose is to convert <strong>base64string</strong> all the way to <strong>blob</strong> so that I could save that in the database. On the other hand, if you know at least part of it such as from <strong>base64string</strong> to <strong>NSData</strong> would be helpful.</p>
  
  <p>Following code would give you the idea of my table</p>
  
  <pre><code>let ItemsDB = Table("Items")
  let idDB = Expression&lt;String&gt;("ID")
  let nameDB = Expression&lt;String&gt;("Name")
  let catDB = Expression&lt;String&gt;("Category")
  let uomDB = Expression&lt;String&gt;("UOM")
  let priceDB = Expression&lt;Double&gt;("Price")
  let imageDB = Expression&lt;Blob&gt;("Image")
  let actDB = Expression&lt;Bool&gt;("Active")
  </code></pre>