title: How to convert bool to NSData
body: <p>I found <a href="https://stackoverflow.com/questions/28680589/how-to-convert-an-int-into-nsdata-in-swift">this post</a> to convert a <code>Int</code> into <code>NSData</code></p>
  
  <p>It says to do this:</p>
  
  <pre><code>var foo: Int = 1000
  let data = NSData(bytes: &amp;foo, length: sizeof(Int))
  </code></pre>
  
  <p>I was wondering, should I do the same think for converting a <code>Bool</code> to <code>NSData</code>, like this:</p>
  
  <pre><code> var purchase: Bool = true
   let data = NSData(bytes: &amp;purchase, length: sizeof(Bool))
  </code></pre>
  
  <p>In my case I always know that the <code>Bool</code> will be true. Since this is the case, I was wondering if there is a simpler method to convert the value "true" to a <code>NSData</code> object.</p>
  
  <p>Some background context:</p>
  
  <p>I am storing this <code>NSData</code> value in the keychain with <a href="https://github.com/kishikawakatsumi/KeychainAccess" rel="nofollow noreferrer">this library</a>.</p>
  
  <p>I am also going to be convert the <code>NSData</code> value back into a bool with <code>NSKeyedUnarchiver.unarchiveObjectWithData</code></p>