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 <mu...@pixar.com> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to