English 中文(简体)
What is an event loop or run loop?
原标题:

In iPhone development, I have come across these terms named

event loop, run loop

. Can some one explain explain what they are?

最佳回答

Like many other GUI systems, the code you write for an iPhone application runs into a loop that is provided by the system. When writing a program without a GUI it is customary to have a main() function or similar. On iPhone you don t have that because it s provided by the system, and it will call the event loop. All you provide is callbacks to react to events.

The loop takes care of getting hardware events as touches and such, calling your code and API code to draw the windows, some memory management and all. This is why you never have to poll for these events yourself.

问题回答

I think this apple documentation will explains a little more:

An event loop is simply a run loop: an event-processing loop for scheduling work and coordinating the receipt of events from various input sources attached to the run loop. Every thread has access to a run loop. In all but the main thread, the run loop must be configured and run manually by your code. In Cocoa applications, the run loop for the main thread—the main event loop—is run automatically by the application object. What distinguishes the main event loop is that its primary input source receives events from the operating system that are generated by user actions—for example, tapping a view or entering text using a keyboard.

https://developer.apple.com/library/ios/documentation/General/Conceptual/Devpedia-CocoaApp/MainEventLoop.html





相关问题
vectors vs. vector graphics

What (if any) is the relationship between vectors used in programming languages (e.g. arrays) and vector graphics? Why do they share the term vector? Does it represent some analogous aspect of their ...

MVC and Property Terminology in Objective-C

I am having a problem with terminology I think. Is a ViewController the Controller portion of MVC? Or is it not the same thing. Is this combining the VC of MVC into one file? Properties like ....

Origin of "map" in Computer Science

In computer science, there are two definitions of the word map. The first is as an associative array, a type of container that maps values of one type to values of another type. An example of this is ...

Definition of the word "patch"

Personally, I use the word "patch" as the software equivalent of a symptomatic treatment, which makes a patch a quick-and-dirty bugfix. However, I m not sure this is correct, because I often see it is ...

What is Facet in JavaEE?

I wonder not only what is Facet but also what is Facet in physical level (as I understand it s not a separate jar, but what?)? I also wonder how can it affect my application after deploying. I ll ...

What is the meaning of "POSIX"?

What is POSIX? I have read the Wikipedia article and I read it every time I encounter the term. The fact is that I never really understood what it is. Can anyone please explain it to me by explaining ...

Term for rotating header

I m looking for terminology that describes this behavior: The header of a web-page contains a different image every time you visit it. Update: It is not an advertisement, but images related to the ...

热门标签