Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why viewDidLoad gets called before viewWillAppear? [duplicate]

Tags:

ios

swift

I want to execute code before view appears but viewDidLoad is getting called before viewWillAppear. Why is it so??

like image 261
Ajinkya Patil Avatar asked Mar 14 '23 03:03

Ajinkya Patil


1 Answers

ViewDidLoad is called when the view is loaded in to memory. i.e if you are using storyboard, the app has unarchived the view and loaded it into memory(not yet on screen).

When the app is ready to load the view on the screen it will call the viewWillAppear method.

In your case, if you want to execute code before the view appears on screen, you could add it in either viewDidLoad or viewWillAppear.

like image 101
TheAppMentor Avatar answered Apr 26 '23 05:04

TheAppMentor