• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Should I use a factory method here?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Should I use a factory method here? (From: "D.K. Johnston" <email@hidden>)

  • Prev by Date: Re: How to force an initial column sort with NSTableView and controller?
  • Next by Date: Re: Background app that can display windows
  • Previous by thread: Should I use a factory method here?
  • Next by thread: Background app that can display windows
  • Index(es):
    • Date
    • Thread