|
In the "Layout and Identity" chapter there is an "Inside TupleView" section with this at the end...
I'm just really confused about what I'm supposed to be seeing here. For one thing, it says "we can use Swift's partial block results builders" but then it tells us to add this extension where we add our own For another thing, it says that "Just having those two partial block builders will cause SwiftUI to nest many TupleView instances" but I don't understand how just adding this extension would cause that. Are we supposed to be writing some additional code to actually use these functions and see that they are actually doing something? |
|
If you look at the Swift proposal SE-0348 One example they use is
These allow up to 10 With
Partial block builders exist as of Swift 5.7 but I don't think they've been adopted in SwiftUI yet.
Nope, you don't need to write any extra code to use those methods. They would get called by the system internals. Per SE-0348, if |
|
I see now. Thank you. So, I can write code like this...
Then, I can see that the extension is working because if I remove the extension I get an error from having more than 10 Views in my VStack. And if I use ModifiedContent<VStack<TupleView<(TupleView<(TupleView<(TupleView<(TupleView<(TupleView<(TupleView<(TupleView<(TupleView<(TupleView<(TupleView<(TupleView<(TupleView<(TupleView<(Text, Text)>, Text)>, Text)>, Text)>, Text)>, Text)>, Text)>, Text)>, Text)>, Text)>, Text)>, Text)>, Text)>, Text)>>, AddGestureModifier<_EndedGesture<TapGesture>>> But without the extension (and removing the extra 5 Views) the type looks like this ModifiedContent<VStack<TupleView<(Text, Text, Text, Text, Text, Text, Text, Text, Text, Text)>>, AddGestureModifier<_EndedGesture<TapGesture>>> |
SPONSORED Let’s face it, SwiftUI previews are limited, slow, and painful. Judo takes a different approach to building visually—think Interface Builder for SwiftUI. Build your interface in a completely visual canvas, then drag and drop into your Xcode project and wire up button clicks to custom code. Download the Mac App and start your free trial today!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.