Re: Newbie question: how to release an object that has been autoreleased
Re: Newbie question: how to release an object that has been autoreleased
- Subject: Re: Newbie question: how to release an object that has been autoreleased
- From: James Bucanek <email@hidden>
- Date: Wed, 22 Sep 2004 08:03:24 -0700
Ondra Cada wrote on Wednesday, September 22, 2004:
>Uh, sorry, but I beg to differ: IMHO, the following pattern is not that
>good.
>
>On 22.9.2004, at 9:29, mmalcolm crawford wrote:
>
>> Buffer *bufferFromPool = [Buffer newBufferFromPool];
>> // ...
>> [bufferFromPool release];
>>
>> ? No autorelease "issues," and more efficient.
>
>Also considerably more prone to programmer's errors of the new/release
>mismatch kind, which is pretty bad. And also prone to leak if an
>exception is raised.
Here's another good reason why this won't work: I can't call the Buffer constructor directly.
The message that creates the Buffer object is a factory method, which creates any of several sub-classes of Buffer depending on the type of the pool. The type information, and the variables needed to initialize the Buffer object, are private to the Pool object. To allow the client to create the Buffer objects directly would destroy my encapsulation.
--
James Bucanek <mailto:email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden