top of page

71. Article: viewDidLoad() in SwiftUI

Writer: Hui WangHui Wang

If you come from the UIKit world, you might wonder what the viewDidLoad() equivalent method in SwiftUI is.


Too bad there is no direct replacement of viewDidLoad() in SwiftUI.


The closest SwiftUI's methods we have are onAppear() and onDisappear() which is equivalents to UIKit's viewDidAppear() and viewDidDisappear().


If you really want the behavior of viewDidLoad(), you have to implement it yourself.


Luckily, the process is not that hard, and this article will help you.





References:


viewDidLoad() in SwiftUI:


 

Follow me on:

Comments


Never Miss a Post. Subscribe Now!

I am an iOS developer, and I will share some knowledge related to iOS development from time to time.

Thanks for submitting!

© 2022 by (Foks) Hui Wang

bottom of page