• 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: Calling a class's methods from within it's +(void)initialize
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling a class's methods from within it's +(void)initialize


  • Subject: Re: Calling a class's methods from within it's +(void)initialize
  • From: Chris Kane <email@hidden>
  • Date: Wed, 3 Aug 2005 08:37:41 -0700

On Aug 1, 2005, at 9:11 PM, email@hidden wrote:

Yeah, so, subject is the question - is it safe to do this? Experimentally it seems to work fine, and there's been a thread or two on singletons which have demonstrated this occurring, but, no one has directly addressed the validity of doing this (that I've been able to find; the archive search on lists.apple.com doesn't allow for literal searches, which makes this topic hard to narrow down).

It is safe.

However, you have some reason for having the +initialize method, something it is doing at first class use, something it is setting up or whatever. It's your responsibility then to make sure that whatever methods you invoke on the class -- and recursively, whatever methods they invoke, and so on -- don't need the result of that work to be finished. Now and in the future. You may have to delicately order the code inside the +initialize in some cases.

I suppose that's obvious. Or, it will be obvious after the first time you debug such a problem. But it's worth pointing out for the record.


Chris Kane Cocoa Frameworks, Apple


_______________________________________________ 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: 
 >Calling a class's methods from within it's +(void)initialize (From: email@hidden)

  • Prev by Date: Re: NSToolbarItem setEnabled Question
  • Next by Date: Re: NSOutlineView and NSTreeController
  • Previous by thread: Re: Calling a class's methods from within it's +(void)initialize
  • Next by thread: NSSegmentedControl Highlights
  • Index(es):
    • Date
    • Thread