Re: Simple instance [[alloc] init] question.

2010-08-31 Thread Kyle Sluder
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

Simple instance [[alloc] init] question.

2010-08-30 Thread Frederick C. Lee
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 =

Re: Simple instance [[alloc] init] question.

2010-08-30 Thread Brian Slick
#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

Re: Simple instance [[alloc] init] question.

2010-08-30 Thread Dave Geering
// 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

Re: Simple instance [[alloc] init] question.

2010-08-30 Thread Charles Srstka
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];

Re: Simple instance [[alloc] init] question.

2010-08-30 Thread Scott Anguish
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

Re: Simple instance [[alloc] init] question.

2010-08-30 Thread mmalc Crawford
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

Re: Simple instance [[alloc] init] question.

2010-08-30 Thread Dave Geering
// 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