Reputation: 2822
I will admit, I found this piece of code online - used it - and boom! I had a big performance boost.
My code looked as follows:
And using Time Profiler, I found that becomingFirstResponder was going nuts, shown here (it's in createOrEditItem):
So I hit the googles and changed it like so:
And Time Profiler isn't even showing it as a "hot" method!
My question is simply, why? What is the technical magic taking place here?
Thanks.
Upvotes: 1
Views: 278
Reputation: 57060
When you asynchronously schedule code to run on the same thread (as you do in your example), you are scheduling it to run on a following runloop cycle.
It does not help performance as much as it shuffles code from one runloop cycle to the next, spreading the workload across multiple runloop cycles, making it appear smoother and faster. If you have side-effects from dummyTextField
becoming first responder, this could also explain a bit why it seems more performant, as, again, the side-effects are pushed to the next runloop cycle.
Upvotes: 1