I just saw the new SwiftData updates, including the DataStore API. I’m wondering if, in the case of a shared remote datastore, it is possible to enable updates to the model context from the datastore without the model context explicitly requesting them (e.g., through database listeners).
If I’m not mistaken, when you use CloudKit with SwiftData, this happens, right?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Why is "Go small with embedded Swift" still not available, despite the fact all the other WWDC24 Tuesday session videos are?
Topic:
Programming Languages
SubTopic:
Swift
I have this sample code:
struct Item: Identifiable {
var id = UUID()
var name: String?
}
struct ItemTable: View {
let items: [Item]
var body: some View {
Table(items) {
TableColumn("Name", value: \.name)
}
}
}
I get the following error:
Key path value type 'String?' cannot be converted to contextual type 'String'
I can solve using \.name!, but I'd like to give a default value instead (something like \.name ?? "default").
How can I achieve this?
I'm trying to make SignInWithAppleButton.Style black when colorScheme is light and white when colorScheme is dark, but .signInWithAppleButtonStyle modifier doesn't update the view when colorScheme change.
struct LogInView: View {
@Environment(\.colorScheme) private var colorScheme
var body: some View {
SignInWithAppleButton { _ in } onCompletion: { _ in }
.signInWithAppleButtonStyle(colorScheme == .light ? .black : .white)
.frame(height: 50)
.padding()
}
}
This can be seen in build and in preview:
struct LogInView_Previews: PreviewProvider {
static var previews: some View {
Group {
LogInView()
LogInView()
.preferredColorScheme(.dark)
}
}
}