NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

Question about where to begin views for SwiftUI project one (We Split)

Forums > 100 Days of SwiftUI

Hey everyone,

I’m trying to work through the We Split project that begins on SwiftUI day 16, and I can’t figure out where to place the code. I’m totally-blind, so I can’t follow along with what Paul is doing in the videos. For example, on day 17 (Reading Text From the User), he mentions, “So, start by adding these three properties to our ContentView struct:” and then provides a few @State properties.

Another example is that he mentions modifying the body property to this: var body: some View {

However, the preexisting body property created by Xcode says: var body: some Scene {

Am I supposed to edit this property, or leave the preexisting property blank and create one from scratch using the code Paul provided? I tried injecting this code, along with all of the other code for the app into the preexisting code that Xcode provides when you first create the project. However, just about every line ends-up being an error.

Thank you!


Since you mention that the code is 'var body: some Scene {' I think that you are editing the 'WeSplitApp.swift' file, whereas you should be editing the 'ContentView.swift' file. This is most likely why you have a lot of errors popping up.

The three state properties are added immediately after the ContentView struct. Followed by the tipPercentages array.

The modification to the 'var body: some View {' is to replace the body content 'Text("Hello World")' with the code he is describing.


Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

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.