Running loops
inti =0; //dead Loop while(YES) {printf ("Please enter an integer, 0 means exit:"); scanf ("%d", &i); NSLog (@"%d", i); if(i = =0) { Break; } }
The above procedures, will continue to circulate, but will be interrupted at the time of input, wait, after the input, and then resume the loop run, and once the composite condition is entered, then by the if judgment, break exits the loop body.
This is the simple Runloop model. In iOS, there are also:
In an iOS application, the system creates an interaction that runs the loop listener user after the application is started.
The abstract expression is:
Before the handwritten code added touch-up listening events to the button, the following code was essentially: registering a listener event in the iOS runloop--run loop!
[Button addtarget:self Action: @selector (click:) forcontrolevents:uicontroleventtouchupinside];
when the run loop detects a button uicontroleventtouchupinside event, A click message is sent to the view controller (self) . That is, the click Method Execution. The essence is to the user click on the Event Listener button, register to run the loop, when the run loop detects the user click the button, call the appropriate method.
IOS Development Notes-Basic UI (9) The concept of running loops