Inter-thread communication in IOS

Source: Internet
Author: User

Cocoa provides two methods for communication between IOS threads, one is mongomselector and the other is port.

Let's talk about the 1st types, which are the following:

2nd are nsmachport methods.Nsport has three subclasses: nssocketport, nsmessageport, and nsmachport, but only nsmachport is available in IOS.

The method used is to register the nsmachport in the receiving thread. If the port is used in another thread to send a message, the registered thread will receive the corresponding message and finally call a callback function in the main thread.

We can see that the result of using nsmachport is to call one function of other threads, and this is exactly what mongomselector is doing, so nsmachport is a chicken rib. Inter-thread communication should all be done through the performselector.

Another method is GCD:

Dispatch_async (dispatch_get_main_queue (), ^ {
Resultstextview. Text = resultssummary;
});

Related Article

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.