Post

Replies

Boosts

Views

Activity

SwiftUI Cloudkit - simple list records from public Db in view
HI All,i am brand new to this and am just starting to learn about swiftui in 2020 so have no knowledge of everything that came before.I have created an app that uses cloudkit. I have a public database with some test data in.All i am wanting is a very basic explanation of how to get that data from the cloudkit public database into a list in my app.I have a a record type called Shoes, in the record i have (brand, name, size)I would like the user to have a list of all shoes that appeer in that database.I would also appreciate filenames to go along with this if there is code in more than one file as i have been getting a little lost with the best practices of where to put code.I know this is a big ask but i cannot find anything simple and strightforward out there in this new iteration of a language.Thanks In Advance,Kind RegardsAdam
2
0
1.2k
Jul ’21
Create @State vars dynamically
Hi, I have a form that will have a number of TextFields depending on the data that is passed in. As i need to record what has been entered into these TextFields, i need state vars. The content is created dynamically but i also need to create the State Vars. Could someone please explain how this would be done. This is my code so far. import SwiftUI struct CandidateReview: View { var reviewScore = ["Terrible", "Poor", "Average", "Good", "Excellent"] var reviewCriterias = ["Communication", "Time Management", "Work Ethic", "Creativity", "Teamwork", "General"] var candidateName = "John Doe" @State private var selectedReviewScore = "Average" @State private var scoreNotes = "" var body: some View { NavigationStack{ Form{ ForEach(reviewCriterias, id: \.self) { reviewCriteria in Section(header: Text(reviewCriteria)){ Picker("\(reviewCriteria) Score", selection: self.$selectedReviewScore){ ForEach(reviewScore, id: \.self){ Text($0) } } NavigationLink(destination: NavigationView { Form { TextField(text: $scoreNotes, label: {}) }.navigationTitle("\(reviewCriteria) review notes") } ){ Text("This is the text that is shown") } } } } .navigationTitle(candidateName) } } } #Preview { CandidateReview() }
2
0
405
Aug ’24