0

I have to call function calculating some thing on MainThread . When calculation process running, I can call UIProgressView to update UI.

When I just call update function, it's working but update UI at last

I use performSelectorInBackground calling update function and it's work fine.

Why use performSelectorInBackground can work

click here to show GIF

I have seen this What's happen if control UI by performSelectorInBackground?, but it not explain why performSelectorInBackground working.

the sample code
https://github.com/g78101/progressViewTest

g78101
  • 1
  • 1
  • 2

1 Answers1

0

I find some soultion

From the doc:
[myObj performSelectorInBackground:@selector(doSomething) withObject:nil];
The effect of calling this method is the same as if you called the detachNewThreadSelector:toTarget:withObject: method of NSThread with the current object, selector, and parameter object as parameters.

BackgroundThread just change the UI value, update UI is runnning on mainThread.

Just NSThrad can work

I think the reason is framework of NSThrad simpler than GCDs

g78101
  • 1
  • 1
  • 2