discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How project center create the app delegate?


From: Ivan Vučica
Subject: Re: How project center create the app delegate?
Date: Fri, 28 Oct 2011 21:15:44 +0200

ProjectCenter is nothing but a program that manages which files are members of a project, and can generate a corresponding GNUmakefile to build the project. ProjectCenter can also generate a project based on a template.

What you are asking is not "what's ProjectCenter doing", but "what's the NSApplication doing at startup time".

There is a nifty little file Info.plist which the NSApplication class reads when it's instantiated. This file contains a specification of the main nib file. This is set to a file with extension .gorm. 

Name "nib file" comes from "NeXTSTEP Interface Builder". It's a name typically used by developers for Apple platforms and other related platforms, such as GNUstep. Apple recently folded the Interface Builder into Xcode, and the source files themselves carry the extension .xib (X standing for XML, probably not for Xcode), while GNUstep uses its interface builder called Gorm. Don't be confused when people talk about "nib files": in context of GNUstep, they actually think about Gorm files.

What does this have to do with anything?

Well, the nib files contain a list of objects that have to be instantiated, along with links between these objects that need to be set up. Nib files under Cocoa, GNUstep and other related platforms (as opposed to iOS) also have a couple of pseudo-objects such as "first responder" and "application". (File's Owner pseudoobject exists on iOS as well).

At runtime, these pseudoobjects are not instantiated. They are instead representing already-existing objects, and may even change with context.

Thus, the answer to your question is:
- NSApplication singleton loads the main nib file
- AppController object is instantiated by the directive of the main nib file. Other objects are set up as well.
- Nib-loading code in GNUstep links the AppController instance with the NSApplication singleton. Specifically, with the "delegate" property, using the function named -setDelegate:. Other links are set up as well.
- NSApplication singleton finishes initialization of itself and calls -applicationDidFinishLaunching: on its delegate.
- -applicationDidFinishLaunching: does its part, and returns control to NSApplication, which resumes the runloop waiting for events such as user input, timer or other system events

Hopefully this clears things up.

On Fri, Oct 28, 2011 at 20:51, Omar Campos <megathodik@gmail.com> wrote:
Hi all,

 After a few months of first discovering GNUStep, I finally decided to read some tutorials on it, to really learn more about it. I am currently reading about the shared application object and its delegate. According to the tutorial, I create an object and implement some methods that control the app's behaviors, such as, 

- (void) applicationWillFinishLaunching: (NSNotification *)not

and then set this object as the application's delegate using [NSApp setDelegate]. So I created a new project in ProjectCenter, to see how this works in the default project template. It seems that the application delegate is an instance of a class called AppController, implemented in AppController.m. There is also a main source file which calls NSApplicationMain(). However, I can't seem to find any place in the code where this class is instantiated and set as the application delegate. So, where does ProjectCenter set this up? How does the program know which class it needs to set as the app delegate? Thanks for any info.

Sincerely,
Omar Campos Rivera

_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep




--
Ivan Vučica - ivan@vucica.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]