Nsrunloop things--Keep on updating

Source: Internet
Author: User

This paper mainly introduces the concept, characteristics and application of nsrunloop.

What is nsrunloop and what is the use?

Let's look at the official definition:

"The NSRunLoop class declares the programmatic interface to objects that manage input sources. An NSRunLoop object processes input to sources such as mouse and keyboard events from the window System, NSPort objects, and c3/> objects. An NSRunLoop object also processes NSTimer events. "

The Nsrunloop type is used to manage the input source. An Nsrunloop object will handle incoming events for mouse, keyboard, Nsport object and Nsconnetion object, and of course nstimer events.

In a word, Nsrunloop is the class used to handle events.

Each thread has its own Nsrunloop object, so we don't have to create the Nsrunloop object, and if you need to, use the Currentrunloop method to get the Nsrunloop object.

Second, nsrunloop when to use

In general, the following four cases will be used in Nsrunloop,

(i) Use ports or custom input sources to communicate and other threads.

Interact with other threads using a port or a custom input source.

(ii) Use timers on the thread.

Use timers in the thread.

(c) Use any of the Performselector ... methods in a COCOA application.

Use any method that starts with Performselector.

(iv) Keep the thread around to perform periodic tasks.

Perform recurring tasks in the thread.

  

Third, how to use Nsrunloop

In fact, we often use the timer when using the Nsrunloop.

Nsrunloop things--Keep on updating

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.