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;
});