But the passed-in closure is meant to run on the main actor, and it is, it's just that the complier doesn't seem to understand that.
Post
Replies
Boosts
Views
Activity
Due to some problem with git, I'd lost the Info.plist definitions of the "Document Types" and "Exported Type Identifiers". Once I added those back, this error disappeared.
Here's a simulator screenshot (iPhone SE). I've marked about where the border is, for the touch events. In my real app, with wider text, it's even further to the right, so that touching the first column of text actually spins the second picker.
Apparently, I can't edit questions here like you can on StackOverflow. This is not caused by Xcode 12.5 exactly, it happened because I followed the suggestion to enable the "Hardened Runtime".
So my question is really: can you unit test when the "Enable Hardened Runtime" build setting is "YES"?
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?
Sorry I don't have an answer, I think it's a great question. I played with your example code and I'm just as puzzled. I hope someone else can answer.
robnotyou, your example with the ZStack partly works for me. The return key triggers the behavior, but the problem is the Button is still visible, as a small blue rounded rectangle, behind the (apparently transparent) TextField.
I'm satisfied with wrapping NSTextField for now. It has some properties and delegate callbacks to more precisely control this behavior.
Workingdogintokyo, it sounds like maybe this has changed in macOS 11.3 beta. I'm running 11.2.3. I pasted your example into a fresh project, and here is the output I get when I start the app, click in the 1st text field, then click in the 2nd text field.
changed 1 ---- commit 1
OOPer, I think you are being too nice, and have maybe too much patience. I would stop watching this thread, and if you like helping people here on the forums, spend time with others who respect your time, post code properly, and answer your questions.
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.
What is the code doing? Is it drawing to a CGContext as you would in a UIView.draw method? If so, it sounds like you have to use UIViewRepresentable to create a UIView that you can then use in a SwiftUI View hierarchy.
If I look at the built binary in Finder (without doing a Clean Build Folder), it does have the updated icon. But running it uses the old icon in the dock and ⌘-Tab app switcher. Odd.
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)
}
}
}
This shouldn't be tagged with "SwiftUI". The Date type is in Foundation and the answer will be the same regardless of whether the app is using SwiftUI, AppKit, UIKit, or the command line.
It's obnoxious isn't it. What did you end up doing? I'm thinking of a few options...
Include HTML in bundle, display in WKWebView within my app.
Include HTML in bundle, send user to web browser to view.
Include a PDF in bundle, send user to Preview or whatever to view it.
Try a Help Book, even though the docs are 8 years old and I see lots of confusing posts online about it.