I created a property for the NSArray which creates a getter/setter. I know Apple recommends using the instance variable in the init and dealloc method. I'm trying to figure what to do in the following code.
(1) Do I need an extra release statement? Wouldn't array have a retain count of 2 then 1 with the dealloc, leave a leak. Or would autorelease take care of this?
(2) Is there some way in xCode or instruments to follow a specific variable to see its retain count going through the process.
@property (nonatomic, retain) NSArray *array;
@synthesize arrary = _array;
- (id)initWithNibName:(NSString *)nibNameOrNil
bundle:(NSBundle *)nibBundleOrNil
initWithArray:(NSArray *)array
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
_array = [[NSArray alloc] initWithArray:array];
}
return self;
}
- (void)dealloc
{
[_array release];
[super dealloc];
}
No comments:
Post a Comment