Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Thomas Harte

macrumors 6502
Original poster
Nov 30, 2005
400
4
If I have a class with a property that is to be retained, e.g.:
Code:
@interface MRDemoClass: NSObject
{
   NSString *name;
}

@property (retain) NSString *name;
@end

// [and, in the implementation file:]

@implementation MRDemoClass

@synthesize name;

@end
Need I manually ensure that any properties retained (such as 'name' in the above example) are released in my dealloc method? Is the answer different if I haven't implemented a dealloc method at all? This is all in a reference counted program, without the benefit of the new garbage collector.
 
Read up on properties =)

@property (nonatomic, copy) NSString *name;
 
Yup. If you've got

Code:
@property (nonatomic, retain) NSString *name;

You need to use in the implementation, a dealloc:

Code:
[name release]
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.