Re: Should I use a factory method here?
Re: Should I use a factory method here?
- Subject: Re: Should I use a factory method here?
- From: Nir Soffer <email@hidden>
- Date: Thu, 22 Jun 2006 22:10:59 +0300
On 22/06/2006, at 20:12, D.K. Johnston wrote:
I have a text view in a window and a controller class that manages
it. There is a one-to-one correlation between these controllers and
their windows. The controller object is the delegate of the window,
and it's told to releases itself when the window closes.
My question is: Should I use a +init factory method to instantiate
the class, instead of the usual [[alloc] -init] procedure?
Do you mean +object... convenience methods? e.g [NSString string]
I _think_ the answer is "yes", since I should never send a release
message to any of these objects; but I'd feel better if I had an
expert second opinion.
It does not matter how you create the object - if you use alloc init,
you have to release it at the end, and if you use a connivence
method, you have to retain the object, and then release it at the
end :-)
The real answer is to read this:
https://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/
MemoryMgmt.html
Best Regards,
Nir Soffer
_______________________________________________
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