How to prevent cocoa application from freezing?

-(void)test
{
  int i;
  for (i=0;i < 1000000;i++)
  {
    //do lengthly operation
  }
}

How to prevent your GUI from freezing?

+3
source share
2 answers

Bottom line; do not block the main thread and thus do not block the main event loop.

Now you can create a stream. But this is actually not the right way to write parallel programs on Mac OS X.

NSOperation NSOperationQueue. , NSOperationQueue , concurrency (# , ..) , .

. .

+5

, NSThread

0

Source: https://habr.com/ru/post/1727450/


All Articles