Post

Replies

Boosts

Views

Activity

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
244
Aug ’24
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
1k
Jun ’20
Where to store dynamic options
I am brand new to iOS app building and resultantly have some basic questions. When building a web app in php for example I would store options in the database. So for example if I had a list of ingredients to add to a shopping list, all of the items that could be chosen would exist in the database and be pulled into the list. My question is, when making an iOS app, where do I store this info so that I can very easily add more options to the list. I don't really want to use json and I don't want to hard code it, nor do I want to use a third party DB. I am assuming that these will be in core data or cloud kit but I can't find the answers I am looking for. Help is appreciated.
0
0
413
Dec ’20
Core Data vs Cloud Kit
Hi All, Just wanting to make sure that I understand this properly. I should be saving data to core data on the device when the user adds stuff to my app. I should then be syncing this using cloud kit to make sure that the data is same across their devices. The benefit of doing it this way allows completely offline use of the app and anything that has been saved to the app on that device. Are the above correct assumptions or am I missing something here. Does a copy the CloudKit private database live on the device for example before it is uploaded. I just want to make sure that pursuing core data as my primary data store is the correct choice here.
0
0
506
Jun ’20
Getting Started With Core Data SwiftUI XCode12
Hi All, I am very new to making apps of this nature (PHP background) and I would love if someone could point me in the direction of / show me some code, of how to set up core data and CRUD. I know there are examples out there but when starting a new cross platform app in Xcode, using 100% swiftUI there isn't much that shows what code should go where and what each bit is doing. We no longer have an app or scene delegate file where a lot of this code was stored previously so I would find it very helpful if this could be spelled out. Also when I move to using iCloud, so that my app can be in the same state on several devices, will there be an issue pulling data from the CloudKit public database and using core data at the same time? Any clarification needed I will happily supply. Thanks in advance, Adam
3
0
1.7k
Jun ’20
Satisfaction Slider SwiftUI
Hi All, I have a slider, @State private var appearance: Double = 4 Slider(value: $appearance, in: 1...7, step: 1) I would like to use this slider for the scale: Terrible, Very poor, Poor, Average ......etc The slider gives me the values 1-7 how can I turn these into a string to show on the screen? Thanks all
4
0
1.8k
Jun ’20
Maintain Navigation When Shifting Tabs
Hi All,I have a very simple IOS app that has 2 tabs currently.When on the first tab, using NavigationViews, i can be 3/4 views deep.When i click tap tab 2 and then back to tab 1 i am not where i was on view 4 but back to view 1 of that tab.Could someone please explain how i would go about making sure that the user goes back to where they were rather than back to view 1.Help is always appreciated.Kind RegardsAdam
1
0
515
Jun ’20
Alphabetic array to use in picker
I have an array that i am using in a picker. I would like this array to be alphabetic.The array isvar item = ["Dog", "Cat", "Ant", "Zoo"] @State private var selectedItem = 0The picker isPicker(selection: $item, label: Text("Item")){ ForEach(0 ..< selectedItem.count){ //this is the made selection Text(self.item[$0]) } }How would i go about making this alpha, i have tried sort() which didnt work for me. It is however, very possible, that i didnt do it right.Help is always appreciated.Kind RegardsAdam
2
0
1.1k
Jun ’20