IOS Development Notes-Basic UI (9) The concept of running loops

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.