title: Objective-C: Potential leak of an object stored into NSDictionary
body: <p>I am a newbie to Objective-C. XCode highlights the following code as an issue.
  <code>_myCookies</code> is a private variable of my class where I store the received cookies.</p>
  
  <pre><code>@implementation MessageSender {
    NSArray *_myCookies;
  }
  ...
  // Socket open callback
  - (void) gotData:(MySocket *) socket {
    NSDictionary *responseHeaders = (__bridge NSDictionary*)CFHTTPMessageCopyAllHeaderFields(socket.HTTPHeaders);
    _myCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:responseHeaders
                                                           forURL:[NSURL URLWithString:@""]];
  
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/7CGzn.png" alt="enter image description here"></p>
  
  <p>The highlighted issues are:</p>
  
  <ol>
  <li>Call to function 'CFHTTPMessageCopyAllHeaderFields' returns a Core Foundation object with a +1 retain count</li>
  <li>Object leaked: object allocated and stored into 'responseHeaders' is not referenced later in this execution path and has a retain count of +1</li>
  </ol>
  
  <p>How do I resolve this one?
  I am using ARC. I want to store the cookies in my class so I can later use them while sending the request, but I want to let the socket take care of its responseHeaders.</p>