• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Main application loop question : what is inside [NSApp run] ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Main application loop question : what is inside [NSApp run] ?


  • Subject: Re: Main application loop question : what is inside [NSApp run] ?
  • From: Dietmar Planitzer <email@hidden>
  • Date: Wed, 5 Mar 2003 00:02:18 +0100

On Tuesday, March 4, 2003, at 06:28 PM, Tristan Lorach wrote:

I'm just trying to do the same as [NSApp run] because I would like to keep
the control over this main loop. My purpose is to write my own loop so that
I can introduce some other processing (OpenGL). I want to do this because I
need OpenGL to be a priority regarding to the rest of the app... Anyway.

Thus I decided to get the Current Loop : [NSRunLoop currentRunLoop] so that
I could call it like :

While(...)
{
[[NSRunLoop currentRunLoop] runUntilDate:NULL];
}

It should properly handle events of the loop. But it doesn't. If ever I only
try this line :

[[NSRunLoop currentRunLoop] run];

Instead of

[NSApp run];

The problem is the same : the mouse events aren't properly handled (buttons
don't react, the window cannot be moved etc)

Any idea of what's inside [NSApp run] ?


The reason for this is that NSRunLoop is conceptually a layer below NSApplication, which means that NSRunLoop has no concept of user events and event dispatching. NSApplication's -run method in fact doesn't even directly use the NSRunLoop -run method, rather it gets the events by repeatedly calling -nextEventMatchingMask: untilDate: inMode: dequeue:. Those events are then dispatched with the -sendEvent: method.

You can find an example of a custom NSApplication -run method in Apple's current GLUT sources which can be found here: <http://developer.apple.com/samplecode/Sample_Code/Graphics_3D/ glut.htm>.
Have a look at the implementation of the -run and -_runMainLoopUntilDate: methods in GLUTApplication.m.


Regards,

Dietmar Planitzer
_______________________________________________
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.

  • Prev by Date: Re: Weird crashes in loading nibs
  • Next by Date: weird build problem
  • Previous by thread: Re: Unix Process ID (and Processes List)
  • Next by thread: Re: Main application loop question : what is inside [NSApp run] ?
  • Index(es):
    • Date
    • Thread