• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
memory mgmt for NSMutableArray as ivar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: memory mgmt for NSMutableArray as ivar
      • From: Andrew Merenbach <email@hidden>
  • Prev by Date: Re: Series of sheets
  • Next by Date: Re: memory mgmt for NSMutableArray as ivar
  • Previous by thread: Re: Series of sheets
  • Next by thread: Re: memory mgmt for NSMutableArray as ivar
  • Index(es):
    • Date
    • Thread