P
P
Petrushka2015-06-17 03:25:21
Objective-C
Petrushka, 2015-06-17 03:25:21

How to speed up controller loading?

Good day, in my controller I have to fill in 25 arrays with rows
, if I initialize them in viewDidLoad, then the transition to the controller (through the button) takes place with a lag (the program sticks)
when I initiate them in viewWillApper, then the transition has become faster
Tell me how and where better to initiate them? Why is the floor faster in the 2nd method (I understand that it is a call when drawing
)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
An, 2015-06-17
@petruska

Long-running tasks should not run in the UI thread at all
Common practice is to put them in the background and then return to the main thread

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    /* долгая операция */

    dispatch_async(dispatch_get_main_queue(), ^{
        /* обновляем ui*/
    });
});

Here is a little more detail idev.by/ios/21112
the general plan is as follows:
1) in init / viewDidLoad - somewhere there you start an operation that takes a long time to run in the background thread
2) Optionally display the spinner
3) When the operation is completed, take the data and update the ui based on it
4) Optionally stop the display of the spinner
4) Profit

S
Stanislav H, 2015-06-17
@shomishinec

As an option Lazy initialization

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question