Why would we use this over just creating an @State variable and returning the view with the binding passed in? I’m not seeing how this is more convenient except for omitting return
So I had a preview @State var x: Int = 0 return IntView(number: $x) where number is Binding But in XCode 16, I get a warning saying @State won't work unless used with @Previewable So it worked for me in XCode 15, but it looks like @State probably wouldn't do anything except prevent an error. So it worked, but not really.
Thanks for the info. Hopefully i can use this to make working with previews easier when dealing with swiftdata.
Thank you 🔥💯
Why would we use this over just creating an @State variable and returning the view with the binding passed in? I’m not seeing how this is more convenient except for omitting return
I thought that doesn't work with the #Preview Macro. That's how it used to be done inside a PreviewProvider (old API)
So I had a preview
@State var x: Int = 0
return IntView(number: $x)
where number is Binding
But in XCode 16, I get a warning saying @State won't work unless used with @Previewable
So it worked for me in XCode 15, but it looks like @State probably wouldn't do anything except prevent an error. So it worked, but not really.
Is preview typing input working?
Entering text with the keyboard does work