Recently I have started implementing swiftUI
. Wondering what is PreviewProvider
? how and when it will be called?
Is it the same as init()
?
Thanks in advance.
PreviewProvider
is a protocol used for generating previews that you can see on the right-hand side in Xcode.
As you can see in the picture you have this preview, but it is only visible when you are using macOS Catalina. The structure that implements it is called when the preview needs to be generated. It hasn't called when you run your app.
You can read more about this protocol in Apple docs