Post

Replies

Boosts

Views

Activity

UserDefaults
I already searched the internet for this, but I couldn't find a complete answer.I have an app with favorites. I want to save these favorites after closing the app.To save the changed data, one can work with Userdefaults.I have the following codeList { Toggle(isOn: $userData.showFavoritesOnly) { Text("show favorites").bold().underline() }In another fileimport Foundation class SettingsViewModel: ObservableObject { @Published var isOn: Bool = UserDefaults.standard.bool(forKey: "isOn") { didSet { UserDefaults.standard.set(self.isOn, forKey: "isOn") } } }Any help is appreciated.
0
0
311
Mar ’20
Problem with VStack
I have the following code in my mainview:var body: some View { NavigationView { List { NavigationLink(destination: CategoryoneList()) { Text("1. ") } NavigationLink(destination: CategorytwoList()) { Text("2. ") } NavigationLink(destination: CategorythreeList()) { Text("3. ") } NavigationLink(destination: CategoryfourList()) { Text("4. ") } NavigationLink(destination: CategoryfiveList()) { Text("5. ") } NavigationLink(destination: CategorysixList()) { Text("6. ") } NavigationLink(destination: CategorysevenList()) { Text("7. ") } NavigationLink(destination: CategoryeightList()) { Text("8. ") } NavigationLink(destination: MainList()) { Text("9. ").bold().underline() } logo() }.navigationBarTitle("Overzicht", displayMode: .inline) .navigationViewStyle(DefaultNavigationViewStyle()) .padding(0) } }Now I want to add my ContactView (with mailadress and whatsApp) under my logo.The problem is that my ContactView is not displayed or I get the error "Argument passed to call that takes no arguments" next to my first NavigationLink.I already tried to put the different views in a VStack seperately, but with no result (first view with my list is not fully displayed).I don't want to work with scrollview, because I want my whole list with navigationlinks fully visible.
1
0
704
Mar ’20
parse a case from enum
I have a detailed json file, where I have the following structure:struct legal: Hashable, Codable, Identifiable { var name: String var place: String var category: Category enum Category: String, CaseIterable, Codable, Hashable { case categoryone = "category One" case categorytwo = "category Two" case categorythree = "category Three" }}Now I want the list of all the names of the category one in one list. How do I extract the data from this file?
12
0
1.6k
Feb ’20