|
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>>> |
SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
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.