Re: Global in NSApplication
Re: Global in NSApplication
- Subject: Re: Global in NSApplication
- From: Graham Cox <email@hidden>
- Date: Wed, 27 Jan 2010 17:02:24 +1100
On 27/01/2010, at 4:43 PM, BareFeet wrote:
> I just wanted to check if there's a simpler way. I guess not.
The singleton pattern Jens suggested is simpler. I can't think of any simpler way:
+ (Debug*) sharedDebug
{
static Debug* s_debug = nil;
if( s_debug == nil )
s_debug = [[self alloc] init];
return s_debug;
}
Then whenever you need the debug object, just call:
[Debug sharedDebug];
The first time it's needed it will be created.
--Graham
_______________________________________________
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