GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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      

Go further, faster with the Swift Career Accelerator.

GO FURTHER, FASTER Unleash your full potential as a Swift developer with the all-new Swift Career Accelerator: the most comprehensive, career-transforming learning resource ever created for iOS development. Whether you’re just starting out, looking to land your first job, or aiming to become a lead developer, this program offers everything you need to level up – from mastering Swift’s latest features to conquering interview questions and building robust portfolios.

Learn more here

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.