Please see sample code
struct Test: View {
var array: [String] = []
init() { }
var body: some View {
Text(String(description: array.count)
}
}
struct Test_Previews: PreviewProvider {
static var previews: some View {
Test(array: ["1", "2", "3"])
}
}
This one is a string array, I wish to pass some values only in preview because in the main view, i will be fetching data from a url. While setting this variable array to an empty array is the solution, what if my variable is a Struct? or Class? How will i make this optional and only supply a new Struct/Class instance in the preview only