@Previewable in Xcode 16 Previews

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ต.ค. 2024

ความคิดเห็น • 7

  • @arukshun2710
    @arukshun2710 4 หลายเดือนก่อน +1

    Thanks for the info. Hopefully i can use this to make working with previews easier when dealing with swiftdata.

  • @andrejkling3886
    @andrejkling3886 4 หลายเดือนก่อน +2

    Thank you 🔥💯

  • @dylanconklin9872
    @dylanconklin9872 4 หลายเดือนก่อน

    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

    • @FloWritesCode
      @FloWritesCode  4 หลายเดือนก่อน

      I thought that doesn't work with the #Preview Macro. That's how it used to be done inside a PreviewProvider (old API)

    • @dylanconklin9872
      @dylanconklin9872 4 หลายเดือนก่อน

      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.

  • @ancientplayer3409
    @ancientplayer3409 4 หลายเดือนก่อน

    Is preview typing input working?

    • @FloWritesCode
      @FloWritesCode  4 หลายเดือนก่อน

      Entering text with the keyboard does work