Re: Cocoa-dev Digest, Vol 2, Issue 1149

  • > From: <ncdev05...>
    > Date: Tue, 26 Jul 2005 06:35:17 -0700
    > Subject: Crash after [NSData dataWithData:(NSMutableData *)]
    >
    >>> NSMutableData * sourceData = [NSMutableData dataWithCapacity:
    >>> [theAnnotatedData length]];
    >>> // append some bytes to sourceData
    >>> NSData * destinationData = [NSData dataWithData:aData];
    >>> [sourceData release];

    -[NSMutableData dataWithCapacity:] is a convenience method, so it
    returns an autoreleased object. Therefore, I think there's no need to
    release it.

    I'm really new to Cocoa, so please, someone correct me if this is wrong.

    Ben
    --
    Ben Kazez
    http://www.benkazez.com/
  • On Jul 26, 2005, at 7:10 AM, Ben Kazez wrote:

    > -[NSMutableData dataWithCapacity:] is a convenience method, so it
    > returns an autoreleased object. Therefore, I think there's no need
    > to release it.

    That is correct.

    > I'm really new to Cocoa, so please, someone correct me if this is
    > wrong.

    When you're right, you're right, and it doesn't matter how long
    you've known the answer.  ;)

    -jcr

    "The problem with trying to child-proof the world, is that it makes
    people neglect the far more important task of world-proofing the
    child." -- Hugh Daniel