For example:
SELECT *
FROM accounts
WHERE (platform, innerID) NOT IN (
('platform_value1', 'innerID_value1'),
('platform_value2', 'innerID_value2'),
...
);
this is hard to use Swift Predicate:
func _fetchAccountNotIn(_ scope: [Account]) throws -> [Account] {
let scope = scope.map{ ($0.platform, $0.innerID) }
return try fetch(.init(predicate: #Predicate<Account> { !scope.contains(($0.platform, $0.innerID)) }))
}
shows compiler error: Cannot convert value of type '(String, String)' to expected argument type '((String, String)) throws -> Bool'
Account definition:
@Model
public final class Account {
#Unique<Account>([\.platform, \.innerID])
#Index<Account>([\.platform, \.innerID])
@Attribute(.preserveValueOnDeletion)
public private(set) var platform : String
@Attribute(.preserveValueOnDeletion)
public private(set) var innerID : String
}
Post
Replies
Boosts
Views
Activity
Is it possible to deploy SwiftData to server? Or is it a good direction to consider improve SwiftData?
Where to download the sample code for WWDC2023 Session 111215 Meet UIKit for spatial computing "Spatial UIKit"?
// continuous version
let continuousClock = ContinuousClock()
let continuousElapsed = try await continuousClock.measure {
try await Task.sleep(until: .now + .seconds(5), clock: .continuous)
}
print(continuousElapsed)
// suspending version
let suspendingClock = SuspendingClock()
let suspendingElapsed = try await suspendingClock.measure {
try await Task.sleep(until: .now + .seconds(5), clock: .suspending)
}
print(suspendingElapsed)
result:
0.000126 seconds
5.324980708 seconds
Swift version: Apple Swift version 5.7 (swiftlang-5.7.0.113.202 clang-1400.0.16.2)
.safeArea does not work with List [Important]
test with iOS 15 beta 4
struct ListTest : View {
var body: some View {
List {
ForEach((0..<50).reversed(), id: \.self) { index in
Text("\(index)")
.listRowBackground(Color.red)
}
}
.listStyle(.plain)
.safeAreaInset(edge: .bottom, alignment: .center) {
Bar()
}
.navigationBarTitleDisplayMode(.inline)
}
}
struct Bar : View {
var body: some View {
HStack {
Spacer()
VStack {
Text("Bar")
Text("Bar")
Text("Bar")
Text("Bar")
}
Spacer()
}
.background(.bar)
}
}
It is ridiculous to use two different versions of Concurrency API for different platforms.
Xcode 13 beta 2 (13A5155e) uses two different versions of Concurrency for iOS and other platforms (e.g. macOS, watchOS, tvOS)!
//
// TestAsyncApp.swift
// Shared
//
//
import SwiftUI
@main
struct TestAsyncApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
@available(iOS 15.0, macOS 12.0, watchOS 8.0, tvOS 15.0, *)
func testAsync() {
#if os(macOS) || os(watchOS) || os(tvOS)
// will trigger error for iOS
Task {
}
Task.detach {
}
#elseif os(iOS)
// will trigger deprecated warning for macOS, watchOS and tvOS
async {
}
asyncDetached {
}
#endif
}
}
What does it mean by "Automatic Inflection" and "Detail Scenes" in SwiftUI part of Platform state of the Union?
Using Button in ToolbarItem is buggy. I use buttons in bottom toolbar.
It cannot show Text and Icon at the same time.
Developers cannot change the tintColor of these buttons separately.
struct ContentView: View {
var body: some View {
NavigationView {
Text("Hello, world!")
.toolbar {
ToolbarItemGroup(placement: .bottomBar) {
Button(action: {}) {
Label("Bookmark", systemImage: "bookmark")
}.accentColor(.green)
Spacer()
Button(action: {}) {
Label("Delete", systemImage: "trash")
}.accentColor(.red)
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
ToolbarItem in the bottomBar cannot show Text and Icon at the same time, and change the tintColor separately.
If I tried it to put a Text and Image into ZStack or HStack, and it will lose the default pointer hover effect in iPad, which is hard to adjust to emulate the default pointer hover effect.