views:

178

answers:

2

I'm using garbage collection in Objective-C 2.0. Do I need to retain properties? Eg.

@property (nonatomic, retain) NSMutableArray *myArray;

Or is this enough:

@property (nonatomic) NSMutableArray *myArray;

I initialize the array like this:

self.myArray = [NSMutableArray array];
+3  A: 

Using the garbage collector you don't have to care about retaining and releasing if you don't write code that should be compatible with legacy objective-c.

-(void)retain and -(void)release are empty functions when the GC is on, they don't change the retain count.

This means leaving it out is fine.

Georg
+2  A: 

retain, release, and autorelease do nothing if the garbage collector is enabled. You can ignore them I believe.