• 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: + (void) initialize not getting called
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: + (void) initialize not getting called


  • Subject: Re: + (void) initialize not getting called
  • From: Andy Lee <email@hidden>
  • Date: Sun, 24 Jul 2011 15:59:12 -0400

Another thought -- is it possible you have a subclass of DBWord that implements +initialize and needs to call super?

--Andy

On Jul 24, 2011, at 3:33 PM, Ken Tozier wrote:

> Hi
>
> I wrote a class that stores data common to all instances in an, init file, but when I create new instances, + (void) initialize isn't getting called. I thought that initialize was always called before anything else, so am a but confused why it isn't working. I don't want to create a global "initialized" flag and have to check that inside every method. Here's a stripped down version of the initialize method. Anyone see what I'm doing wrong? Is there any other way to insure that initialize is called before any other method in the class?
>
> static NSMutableString			*gSharedData				= nil;
>
> @implementation DBWord
>
> + (void) initialize
> {
> 	@synchronized(self)
> 	{
> 		if (gSharedData == nil)
> 		{
> 			NSLog(@"made it to here");
>
> 			NSError		*error		= nil;
> 			gSharedData	= [[NSMutableString alloc] initWithContentsOfFile: @"/path/to/shared/file.txt" encoding: NSUTF16StringEncoding error: &error];
> 		}
> 	}
> }
>
> ...
>
> @end
>
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: + (void) initialize not getting called
      • From: Jens Alfke <email@hidden>
References: 
 >+ (void) initialize not getting called (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: + (void) initialize not getting called
  • Next by Date: Re: More on drawRect not getting called
  • Previous by thread: Re: + (void) initialize not getting called
  • Next by thread: Re: + (void) initialize not getting called
  • Index(es):
    • Date
    • Thread