memory mgmt for NSMutableArray as ivar
memory mgmt for NSMutableArray as ivar
- Subject: memory mgmt for NSMutableArray as ivar
- From: Daniel Child <email@hidden>
- Date: Wed, 22 Aug 2007 00:21:15 -0400
Hi all,
I am trying to set up a class where one of the instance variables is
an NSMutableArray, and want to deal with the memory issues. I've
looked at several of the recommended readings on memory management,
but cant seem to find an example where the instance variable is an
array.
Specifically, does the array need to be somehow allocated and
initialized during the init method used when creating class
instances? If so, how?
I tried Accessorizer, and it produced the following code for a basic
class with an array instance variable:
(in header file)
@interface MyClass : NSObject {
NSMutableArray *list;
}
@end:
(in implementation file)
// init
- (id)init
{
if (self = [super init])
{
[self setList: <#(NSMutableArray *)theList#>];
}
return self;
}
// list ACCESSORS
- (NSMutableArray *) list
{
return [[list retain] autorelease];
}
- (void) setList: (NSMutableArray *) theList
{
[list release];
list = [theList copy];
}
This compiled fine, but I have no idea what the <#....#> part means,
and have not encountered this in the literature. Can someone explain
how this works? Or an alternate safe approach.
Thanks!
Daniel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden