Post

Replies

Boosts

Views

Activity

Reply to Massive Memory Leak in SwiftUI for macOS
I just pasted your code into Xcode, ran it, and started clicking around. It seems a bit bogged down, because it can take over a second to change the VeryComplexView when I click on the different numbers in the left nav. But, the memory use is staying around 100-150MB. I'm running macOS 11.2.3, so maybe you could try upgrading to that?
Mar ’21
Reply to Differentiating between "return" and focus loss in TextField onCommit
Sorry, I don't follow. There is no action: parameter for TextField, so what is would get triggered by the keyboard shortcut? I tried putting the modifier on it anyway, but the behavior is the same. TextField("Search", text: $searchQuery) { editing in .... } onCommit: { ... // still triggered by return OR focus loss }.keyboardShortcut(.defaultAction) I ended up using NSViewRepresentable and wrapping an NSTextField. So I have something working now, but I'd prefer to use pure SwiftUI if I can.
Mar ’21
Reply to Looking for opinions - Math Tables in a List
Are you asking how to generate the list dynamically? Here is one way below. You can't have a for loop directly in the body of a SwiftUI view. Maybe in the future, but for now you have to use the ForEach thing. func makeTables() - [String] {     var result = ["Temporary"]     for i in 1...20 {         result.append("\(i) + \(i) = \(i+i)")     }     return result } struct ContentView: View {     var tables: [String] = makeTables()     var body: some View {         NavigationView {             List {                 ForEach(self.tables, id: \.self) { show in                     HStack {                         Image(systemName: "arrow.right")                             .resizable()                             .frame(width: 30, height: 20, alignment: .center)                         Text(show)                             .font(.custom("Chalkboard", size: 50))                     }                 }             }.navigationBarTitle(Text("Addition Tables (1 - 20)"))             .navigationBarTitleDisplayMode(.inline)         }     } }
Mar ’21