Hi,
I'm learning SwiftUI and there are still some things I don't understand very well.
For example, this is compiling correctly:
This is also compiling correctly:
But if I create a View that contain both a binding and a private property:
the compiler produce this error:
Thank you
I'm learning SwiftUI and there are still some things I don't understand very well.
For example, this is compiling correctly:
Code Block struct Test: View { private var testPrivateProperty = 1 var body: some View { Text("Test") } } struct Test_Previews: PreviewProvider { static var previews: some View { Test() } }
This is also compiling correctly:
Code Block struct Test: View { @Binding var testBinding: Bool var body: some View { Text("Test") } } struct Test_Previews: PreviewProvider { static var previews: some View { Test(testBinding: .constant(true)) } }
But if I create a View that contain both a binding and a private property:
Code Block struct Test: View { @Binding var testBinding: Bool private var testPrivateProperty = 1 var body: some View { Text("Test") } } struct Test_Previews: PreviewProvider { static var previews: some View { Test(testBinding: .constant(true)) //Error on the line above. } }
the compiler produce this error:
Can anyone help me understand why?'Test' initializer is inaccessible due to 'private' protection level
Thank you