Re: Loading arrays into register
Re: Loading arrays into register
- Subject: Re: Loading arrays into register
- From: "Simon" <email@hidden>
- Date: Sat, 29 Dec 2007 16:00:22 -0500 (EST)
"the Sinewave class has no autorelease pool" doesn't actually mean anything, so I think you haven't understood what autorelease does. Objects allocated by [Whatever alloc] don't get put in the current autorelease pool until you send them an autorelease message; for your convenience the methods that implement things like [NSMutableArray arrayWithCapacity: 100] will both allocate the object and send it an autorelease message on your behalf. What this means for you in practice is that objects you allocate with [Whatever alloc] have to be explicitly released (or autreleased), whereas all other objects have to be explicitly retained if you want them to last between times around the event loop. In particular, the number of times you'll ever need to create your own autorelease pool cant be counted on Captain Hook's fingers."
Thanks for the advice. I realised the reason I was having problems was simply because I wasn't copying the objects from the NSMutableArray to the NSArray.
I had code like this:
NSArray * anArray;
NSMutableArray * aMutableArray = [[NSMutableArray alloc] init];
anArray = aMutableArray;
[aMutableArray release];
[[anArray objectAtIndex: anIndex] doSomething];
Which I've now changed to:
NSArray * anArray;
NSMutableArray * aMutableArray = [[NSMutableArray alloc] init];
anArray = [aMutableArray copy];
[aMutableArray release];
[[anArray objectAtIndex: anIndex] doSomething];
Now everything is hunky-dory!
Thanks,
Simon
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden