UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Project 2 (day 20) factual error? (argh, wrong forum, should be 100 days of SwiftUI)

Forums > 100 Days of Swift

Hello, on this page: https://www.hackingwithswift.com/books/ios-swiftui/using-stacks-to-arrange-views

There is text which reads:

Let’s try it out now. Our default template looks like this:

var body: some View {
    VStack {
        Image(systemName: "globe")
        Text("Hello, world!")

That returns precisely one kind of view, which is a text view.

But that's incorrect, isn't it? It returns a VStack view, not a Text View.

Perhaps the template has changed since the article was written and the template text was updated for iOS 17 and the text was not...


Orginal Template when making a new app was this.

var body: some View {
    Text("Hello, world!")

but now has changed. Paul may of missed the text to change, And to be fair (in video) do not say this)

PS It does not return a VStack but return more complicated View that has VStack, Image, Text and the modifier think later he does show you.

If you find anything typo, etc best to email Paul directly perferable with link to the error so he can correct it.



Just for clarity, what type does get returned from the new boilerplate? I assume that it only returns one instance (which conforms to the View protocol) and not a tuple or anything.

From my old OO/imperative mindset I would have assumed that the Result Builder would return a VStack struct with child views in a nested hierarchy. But perhaps that's not how it works...?



Hi @Diggory

It return

ModifiedContent<ModifiedContent<VStack<TupleView<(ModifiedContent<ModifiedContent<Image, _EnvironmentKeyWritingModifier<Scale>>, _ForegroundStyleModifier<TintShapeStyle>>, Text)>>, _PaddingLayout>

or some View

Check out Why does SwiftUI use “some View” for its view type?


BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.