On 24 Jun '08, at 8:34 PM, JArod Wen wrote:

I am a cocoa newbie from Java. Recently I found an example code in which the instance of a class is defined in its own class's header file, as following:
@interface AppController : NSObject {
        // Instance variables here
}
AppController *appController;

That's not valid code as you wrote it … I think you meant to put an "@end" after the "}"? In that case, "appController" is a declaration of a global variable, a pointer to an AppController instance. This is a pretty common thing to do: the global variable points to the singleton instance of AppController, as a quick way to let other code call methods on it. Usually AppController initializes the variable like so:
        - (void) awakeFromNib {
                appController = self;
        }

Now if some other code in the app wants to, say, open the preferences panel, it can call [appController openPrefs: self].

—Jens_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to