• 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
Fwd: -init is not being called on my custom class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: -init is not being called on my custom class


  • Subject: Fwd: -init is not being called on my custom class
  • From: James Spencer <email@hidden>
  • Date: Sun, 9 Feb 2003 10:43:32 -0600

On Sunday, February 9, 2003, at 08:34 AM, mw wrote:

I have a custom class called CoreApplication. It is a singleton, and for
some reason, it's -init method isn't being called. Here is some sample code
to help:

// the singleton accessor
+ (id)sharedApplicationModel
{
if (!sharedInstance) {
sharedInstance = [[CoreApplication alloc] init];
}
return sharedInstance;
}

...

+ (id)alloc
{
if (!sharedInstance) {
self = [super init];
return self;
} else {
return nil;
}
}

You aren't creating an instance and the self you return is a reference to the Class object, not the instance consequently,
it won't call your instance method, -init.

Spence

James P. Spencer
Rochester, MN

email@hidden

"Badges?? We don't need no stinkin badges!"
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: -init is not being called on my custom class
  • Next by Date: Re: Duplicating Apple search field UI
  • Previous by thread: Re: -init is not being called on my custom class
  • Next by thread: Deprecated menu methods (was Re: Updating menu items in a status bar item)
  • Index(es):
    • Date
    • Thread