Re: Global in NSApplication
Re: Global in NSApplication
- Subject: Re: Global in NSApplication
- From: BareFeet <email@hidden>
- Date: Wed, 27 Jan 2010 16:43:43 +1100
Yes, I'm familiar with categories, but didn't mention it because it's
so similar to subclassing.
I just wanted to check if there's a simpler way. I guess not.
Thanks,
Tom
BareFeet
Sent from my iPhone
On 27/01/2010, at 1:17 PM, Murat Konar <email@hidden> wrote:
Read up on categories. Then make the instance of your Debug class a
static variable in your category implementation file, and use a
method you added to NSApplication via your category to return it.
<http://en.wikipedia.org/wiki/Objective-C#Categories>
_murat
On Jan 26, 2010, at 6:05 PM, BareFeet wrote:
Hi all,
I've created a "Debug" class in my app, which contains an instance
variable and several methods. I want to add this to my application
but can't see how.
I can add it to MyDocument class like this:
- (id)init
{
self = [super init];
if (self) {
// other stuff
debug = [Debug new];
}
return self;
}
- (void) dealloc
{
// other stuff
[debug release];
[super dealloc];
}
But I want a global instance for the application as a whole. How do
I do this? Do I have to subclass NSApplication just to create a
global variable?
I want to be able to call it from any class in my app, such as:
[[NSApp debug] myMethod];
Please reply to the list.
Thanks,
Tom
BareFeet
--
Comparison of SQLite GUI tools:
http://www.tandb.com.au/sqlite/compare/?ml
_______________________________________________
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