|
Hi, I'm puzzled by task two. I don't recall any of the tutorials in project 8 covering the process of moving individual code chunks to a different view. When I looked it up, I found this video: Link but I'm somewhat hesitant to use a method different from the ones Paul teaches. Can you guide me to the tutorial in project 8 where Paul discuss moving code to other views? Thanks! |
|
Im really confused how to connect these two swift views. In this new CrewScrollView.swift i only have this :) I have no idea how to connect this file to MissionView.swift
|
|
I just looked back at the lessons for project 8, and can't seem to find what you are looking for. I wonder if that section got deleted at some point, but the challenge questions were not re-written to account for that. In this lesson, https://www.hackingwithswift.com/books/ios-swiftui/merging-codable-structs Paul basically walks you through how to add a ScrollView of astronauts in That way, we can basically take all of that code that we had previously written in MissionView.swift, move it to a separate file (CrewScrollView.swift) and replace all that code in MissionView.swift with one line of code. A call to the initializer for
Because Now, the MissionView.swift file is much easier to look at, and that's basically all this is trying to accomplish. In the challenge, Paul wants you to do that same thing with the rectangle dividers that he had you create in the same lesson.
He asks you to add this to MissionView.swift in 2 different places. But that is taking up 8 lines of code. So, you could make this into a separate View to declutter MissionView.swift even further. Since these are being used as dividers, you could create a new file called RectangleDividerView.swift (or something like that) and then try to create your own view that creates the same thing as shown above. But then you can replace those 8 lines of code in MissionView.swift with just 2 lines of code instead. |
|
Hi! Thanks for the response. So, I didn't go crazy, and there wasn't any mention of how to move a piece of code to a new file earlier, right? 😄
I googled it, and I think the simplest way to do it is indeed by using structs but my problem was how to connect the code from CrewScrollView to MissionView. ChatGPT suggested that I needed to create |
|
Hi again @Fly0strich Im trying third task and i got this code:
But i got error: "Cannot find 'columns' in scope" What am i doing wrong here? :) |
|
You are trying to use This line of code is in my project, but I don't remember if it's something that Paul gave us to use. I assume so.
|
SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today!
Sponsor Hacking with Swift and reach the world's largest Swift community!
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.
Link copied to your pasteboard.