Post

Replies

Boosts

Views

Activity

Reply to Save List data to device (another expansion)
Not on there. This is what it's suggesting: Similar solutions… How to handle unknown properties and methods using @dynamicMemberLookup How to create a project using Swift Package Manager How to fix “argument of #selector refers to instance method that is not exposed to Objective-C” How to install a beta version of Swift How to subclass UIApplication using UIApplicationMain I don't think that any of these correlate with my JSON problem, but please correct me if I'm wrong.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’21
Reply to Save List data to device (another expansion)
I found a Hacking with Swift page (hackingwithswift.com/example-code/language/how-to-convert-json-into-swift-objects-using-codable) showing how to convert JSON into Swift objects. It's pretty straightforward, though, I need to figure out how to convert cardsInfo to JSON, if at all, and if that's what I need to convert.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’21
Reply to Save List data to device (another expansion)
...you should better consider using Coding. With making CardInfo conform to Codable, you can easily convert whole Array of CardInfo into Data. And Data can be easily writable to a file. Where should I start with this? Or should I just Google something like "convert whole array to data codable?"
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’21
Reply to Force color scheme at the press of a button
Please show your latest code if you cannot solve the issue yourself. ContentView: // //  ContentView.swift //  Shared // //  Created by Joshua Srery on 12/17/20. //  Additional code by OOPer on Apple Developer Forums // import SwiftUI struct ContentView: View {     @Environment(\.colorScheme) var systemColorScheme     @State var myColorScheme: ColorScheme?     var body: some View {         TabView {             CardsView()                 .tabItem {                     Image(systemName: "person.crop.square.fill.and.at.rectangle")                     Text("Cards")                 }             SettingsView(colorScheme: $myColorScheme)                 .tabItem {                     Image(systemName: "gear")                     Text("Settings")                 }         }         .colorScheme(myColorScheme ?? systemColorScheme)     } } SettingsView: // //  SettingsView.swift //  Lunch Card (iOS) // //  Created by Joshua Srery on 12/21/20. //  Additional code by OOPer on Apple Developer Forums. // import SwiftUI struct SettingsView: View {     @State private var selectedAppearance = 1     @Binding var colorScheme: ColorScheme?     var body: some View {         NavigationView {             Form {                 Section(header: Text("Customization")) {                     Picker(selection: $selectedAppearance, label: Text("Appearance")) {                         Text("System Default").tag(1)                         Text("Light").tag(2)                         Text("Dark").tag(3)                     }                     .onAppear {                         switch colorScheme {                         case .none:                             selectedAppearance = 1                         case .light:                             selectedAppearance = 2                         case .dark:                             selectedAppearance = 3                         default:                             break                         }                     }                     .onChange(of: selectedAppearance) { value in                         //print(selectedAppearance)                         switch selectedAppearance {                         case 1:                             //print("System Default")                             colorScheme = nil                         case 2:                             //print("Light")                             colorScheme = .light                         case 3:                             //print("Dark")                             colorScheme = .dark                         default:                             break                         }                     } ///... }
Topic: App & System Services SubTopic: General Tags:
Jan ’21
Reply to I have a function in one view, but a button that should call it in another
This didn't work. I put showSheetView into a shared object, SheetInfo, and called it in both CardsView and AddView as sheetInfo. I changed every declaration of $showSheetView to $sheetInfo.showSheetView. Still didn't work. Is there something I missed? Here's the code: SheetInfo: class SheetInfo: ObservableObject { @Published var showSheetView = false } CardsView: struct CardsView: View {     @StateObject var cardsInfo = CardsInfo()     @StateObject var sheetInfo = SheetInfo() // <-     @State private var editMode = EditMode.inactive          var body: some View { (...) ToolbarItem(placement: .navigationBarTrailing) {         Button(action: {             self.sheetInfo.showSheetView.toggle()                 }) {                     Image(systemName: "plus")                     }.sheet(isPresented: $sheetInfo.showSheetView) {                     AddView(cardsInfo: cardsInfo, sheetInfo: sheetInfo, isShowing: $sheetInfo.showSheetView)                     }                 } (...) } AddView: struct AddView: View {     @ObservedObject var cardsInfo: CardsInfo     @ObservedObject var sheetInfo: SheetInfo     @Binding var isShowing: Bool   var body: some View { (...) Button(action: { cardsInfo.add() isShowing = false }) { Text("Create") .bold() } (...) }
Topic: App & System Services SubTopic: General Tags:
Jan ’21