Re: Files and arrays
Re: Files and arrays
- Subject: Re: Files and arrays
- From: Ondra Cada <email@hidden>
- Date: Sat, 16 Nov 2002 16:14:59 +0100
On Saturday, November 16, 2002, at 04:02 , Jim Balhoff wrote:
The buggy code is purely my own.
You won't get it patented anyway, for others did it before ;)
Well to cut the long story short, whenever you create an object to put it
into an automatic variable (or into another object), ensure it is
autoreleased (or shared):
{
id local=[AClass aClassWith...];
id local2=[[[AClass alloc] initWith...] autorelease];
...
[anArray addObject:[AClass aClassWith...]];
[anArray addObject:[[[AClass alloc] initWith...] autorelease]];
}
Only in case you store the object into a global or instance variable, you
should use [[AClass alloc] initWith...], or the practically equivalent
(unnoticeably less effective) [[AClass aClassWith...] retain].
(Of course there are exceptions to this rule, but they are just that --
exceptions, for cases where there is a hard reason to do it some other way.
)
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.