Re: Program flow in NSApplication
Re: Program flow in NSApplication
- Subject: Re: Program flow in NSApplication
- From: Tom Sutcliffe <email@hidden>
- Date: Mon, 28 Apr 2003 17:47:02 +0100
<Removed what I was going to say here as publiclook answered first>
By looking at stack traces in the debugger, and the documentation for
NSApplication, flow of execution goes something like
main.m calls the NSApplicationMain function.
NSApplicationMain initialises the main nib file and the NSApp object.
init methods of classes in the main nib file run next (at this point
any NSViews etc in the classes will be nil).
then the connections are made in the nib - NSViews are created etc
(although this might happen slightly earlier).
awakeFromNib called on classes instantiated by the nib (here the
NSViews etc are guaranteed to be initialised).
NSApplicationMain then calls [NSApp run] which calls [NSApp
finishLaunching].
Any windows in the nib that were marked as 'visible at launch time' are
put on screen about now.
[NSApp finishLaunching] posts applicationWillFinishLaunching
notification (which also causes the NSApp delegate to get
applicationWillFinishLaunching: called).
[NSApp finishLaunching] opens any files (if the app was launched by
double-clicking on one of its files).
[NSApp finishLaunching] posts applicationDidFinishLaunching in similar
way to willFinish, above.
control returns to [NSApp run] which starts the event loop.
Regards,
Tom
On Monday, April 28, 2003, at 03:31 pm, Andreas Schempp wrote:
Do get the applicationWillFinishLaunching and the other four functions
to
work, you have to register your application at the notification center.
you should do something like this:
- (void) awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillFinishLaunching:)
name:@"NSApplicationWillFinishLaunchingNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidFinishLaunching:)
name:@"NSApplicationDidFinishLaunchingNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillBecomeActive:)
name:@"NSApplicationWillBecomeActiveNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidBecomeActive:)
name:@"NSApplicationDidBecomeActiveNotification" object:nil];
}
And check for spelling errors ;-)
Hi,
I have created a sample application in Cocoa using a
custom view. i then subclassed the view from
NSScrollView.
Now in the code all the coding for creating the
matrix and NSButtonCells in the matrix is done in -
(id)initWithFrame:(NSRect)frameRect
I have a delegate from the FistOwner to class instance
controller. I have defined functions like
-(void)applicationWillFinishLaunching:(NSNotification
*)aNotification
{
}
- (void)applicationDidBecomeActive:(NSNotification
*)aNotification
{
}
- (void)applicationDidFinishLaunching:(NSNotification
*)aNotification
{
}
- (void)applicationWillBecomeActive:(NSNotification
*)aNotification
{
}
just for testing purpose to find whether the program
control reaches any of these functions. but i found
that - (id)initWithFrame:(NSRect)frameRect function
finishes all the processing and control does not reach
the 4 functions mentioned above.
i had also used -(void)awakefromNib function. But
when the program starts executing the control first
goes to - (id)initWithFrame:(NSRect)frameRect.
What could be going wrong or is this the normal
behaviour?
Is there any documentation available which tells the
flow of the program for NSApplication.
Thanks.
with rgds,
johnd
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.