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 11:32:10 -0700
mmalcolm crawford wrote on Wednesday, September 22, 2004:
>
>On Sep 22, 2004, at 8:03 AM, James Bucanek wrote:
>> 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.
>>
>We'll have to agree to differ on this, then...
>
>> 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.
>>
>It's again not clear why this won't work.
I would. I had confused this comment with another one that suggested that I replace [[pool bufferFromPool] with [[Buffer alloc] initFromPool:pool].
Sorry for the confusion.
--
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