TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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")
            .imageScale(.large)
            .foregroundStyle(.tint)
        Text("Hello, world!")
    }
    .padding()
}

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...

3      

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.

3      

Thanks.

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...?

https://www.hackingwithswift.com/swift/5.4/result-builders

3      

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?

4      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

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.