On Aug 30, 2010, at 9:36 PM, Dave Geering dlgeer...@gmail.com wrote:
I apologise. I was going to explain each one in terms of ownership,
but I couldn't figure out a way to explain how you own something twice
without talking about reference counts. I should probably refrain from
replying to
Which is the preferred method of object allocation initialization?
header file.h
@property(nonatomic, release) IRMSerialDetailsDO *serialIDs;
...
body.m
@synthesize mySerialIDDO
...
// 1)
self.serialIDs = [[IRMSerialDetailsDO alloc] init];
or...
// 2)
IRMSerialDetailsDO *mySerialIDDO =
#1 is a leak.
(I'm assuming that release is supposed to be retain in the property
declaration)
Brian
On Aug 30, 2010, at 8:23 PM, Frederick C. Lee wrote:
Which is the preferred method of object allocation initialization?
header file.h
@property(nonatomic, release) IRMSerialDetailsDO
// 1)
self.serialIDs = [[IRMSerialDetailsDO alloc] init];
The alloc method allocates an instance with a retain count of 1, and
assigning it to the serialIDs property bumps it up to 2. In your
dealloc method, you will [hopefully] send it a release message which
puts it back at 1, but this means
On Aug 30, 2010, at 7:23 PM, Frederick C. Lee wrote:
// 1)
self.serialIDs = [[IRMSerialDetailsDO alloc] init];
This is, as mentioned, a leak, although if performance is not an issue, you can
still have the simplicity:
self.serialIDs = [[[IRMSerialDetailsDO alloc] init] autorelease];
Assuming his @property was supposed to be (nonatomic,retain)
We did the release explicitly when doing some sample code on iPhone. We didn’t
want the autorelease pool to grow.
IRMSerialDetailsDO *mySerialIDDO = [[IRMSerialDetailsDO alloc] init];
self.serialIDDO = mySerialIDDO;
[mySerialIDDO
On Aug 30, 2010, at 6:37 PM, Dave Geering wrote:
// 1)
self.serialIDs = [[IRMSerialDetailsDO alloc] init];
The alloc method allocates an instance with a retain count of 1, and
assigning it to the serialIDs property bumps it up to 2. In your
dealloc method, you will [hopefully] send it a
// 1)
self.serialIDs = [[IRMSerialDetailsDO alloc] init];
The alloc method allocates an instance with a retain count of 1, and
assigning it to the serialIDs property bumps it up to 2. In your
dealloc method, you will [hopefully] send it a release message which
puts it back at 1, but this