Re: Memory Management: Revamped Engine Example
Re: Memory Management: Revamped Engine Example
- Subject: Re: Memory Management: Revamped Engine Example
- From: Greg Herlihy <email@hidden>
- Date: Sun, 01 Jan 2006 16:33:53 -0500
This program looks much better. I have just one suggestion relating to style
(see below).
On 1/1/06 5:12 AM, "Jordan Evans" <email@hidden> wrote:
> @interface Engine : NSObject
> {
> NSMutableArray *enginePartsArray;
> }
>
> - (id)init;
> - (void)maintenance:(NSMutableIndexSet*)badParts;
>
> @end
>
>
> @implementation Engine
>
> - (id)init;
> {
> int i;
>
> [super init];
>
> enginePartsArray = [[NSMutableArray alloc] init];
>
> [enginePartsArray addObject:[[CombustionChamber
> alloc] init]];
> [enginePartsArray addObject:[[Compressor alloc]
> init]];
> [enginePartsArray addObject:[[FuelInjector alloc]
> init]];
> [enginePartsArray addObject:[[FuelInjector alloc]
> init]];
> [enginePartsArray addObject:[[Shaft alloc] init]];
> [enginePartsArray addObject:[[Turbine alloc] init]];
> for( i=0; i<[enginePartsArray count]; i++ )
> [[enginePartsArray objectAtIndex:i] release];
Explicit loops are inelegant. I would suggest replacing the line above with:
[enginePartsArray makeObjectsPerformSelector:@selector(release)];
Greg
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden