title: Different Values in Memory when using NSData vs NSMutableData
body: <p>I'm trying to write some code that assembles packets to send over a network; however, I've run into problems with the assembled packets. Here's some code illustrating my situation:</p>
  
  <pre><code>NSMutableData *data1 = [NSMutableData dataWithLength:3];
  NSData * data2 = [[NSData alloc] initWithBytes:(unsigned char[]){0xAA, 0xAA, 0xAA} length:3];
  [data1 appendBytes:(unsigned char[]){0xAA, 0xAA, 0xAA} length: 3];
  </code></pre>
  
  <p>When I set a breakpoint and read the values of memory for <code>*data1</code> and <code>*data2</code>, <code>data1</code> only has garbage values in it, whereas <code>data2</code> will have the <code>0xAA</code>'s in memory.</p>
  
  <p>I looked at the Apple developer reference, but didn't seem to find anything related. One interesting thing I noted though, was that the initialization of <code>data1</code> should have zeroed out the bytes, which I'm also not really seeing.</p>
  
  <p>So I'm wondering if there's some obvious mistake I'm making in my code, or some fundamental misunderstanding of the NSData/MutableData objects, seeing as I'm pretty new to Objective C? Any help would be appreciated. Thanks!</p>
  
  <p>Edit: I'm dumb...turns out if I look at memory of <code>data1</code>, not <code>*data1</code>, I can find the values that I append.</p>