Fwd: -init is not being called on my custom class
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.