Can I use viewWillAppear instead of viewDidLoad for most of my initialization and setup?
It depends on what you intend to do after the form starts-to-finish loading the submission.
You don't want to do too much in viewWillAppear
(Called when the view is ready to be shown) as this can impact performance; typically you want to do things like update a table or update text on a label, etc. The method viewDidLoad
is called after the view has loaded, and it is usually possible to add things like buttons, labels, etc., whatever you want displayed on the screen. If you have some tasks that can take a long time, it is better to do them viewDidAppear
as soon as the view is already loaded; it is good practice to execute these methods on a separate thread, or at least provide the user with some kind of activity indicator until the job is done.
source to share