Post

Replies

Boosts

Views

Activity

How to write predicate to express not-in for compound index?
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 }
1
0
500
Aug ’24
ContinuousClock not working for sleeping
// 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)
1
0
1.1k
Jun ’22
.safeArea does not work with List [Important]
.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)     } }
0
0
1.1k
Jul ’21
Xcode 13 beta 2 (13A5155e) uses two different versions of Concurrency for iOS and other platforms (e.g. macOS, watchOS, tvOS)
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     } }
2
0
1.4k
Jun ’21