title: How to convert NSValue to NSData and back?
body: <p>A have a number of <code>NSValue</code> (obtained via KVC <code>valueForKey</code>) that I need to append to an <code>NSData</code> object in order to send it over the network using Game Center. Obviously I will also need to convert the <code>NSValue</code> back from <code>NSData</code> for more KVC (<code>setValue:forKey:</code>). </p>
  
  <p>I don't know the exact type of each <code>NSValue</code>, so I'm limited to using the interfaces provided by <code>NSValue</code> and <code>NSData</code>. I should mention that the <code>NSValue</code> are never pointer types.</p>
  
  <p>I'm surprised that there's no <code>[NSData dataWithValue:value]</code> and neither something like <code>[value dataWithEncoding:]</code> or similar. But maybe I'm blind and not seeing the obvious choice. I thought about using <code>getValue:</code> to copy the value into a <code>void*</code> buffer, but how am I supposed to determine the buffer length other than by using <code>objCType</code> and comparing that with all possible types?</p>
  
  <p>How should I go about this?</p>
  
  <p><strong>NOTE:</strong>
  <code>NSKeyedArchiver</code> is out of the question because it is terribly inefficient. A 4 Byte float is archived to a 142 Bytes <code>NSData</code>, a 8 Byte <code>CGPoint</code> uses 260 Bytes when archived to <code>NSData</code>. Keeping the amount of data sent to a minimum is crucial to what I'm doing.</p>