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
303
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
988
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
936
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.3k
Jun ’21
ToolbarItem with Button Problem
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.
1
0
1.1k
Nov ’20
isDetailLink(false) will act strange with GroupListStyle
If you use `DoubleColumnNavigationViewStyle` with a `NavigationView`struct ContentView: View { var body: some View { // Navigation View NavigationView { // Master View MasterView() }.navigationViewStyle(DoubleColumnNavigationViewStyle()) } }and in the `MasterView`, you use a NavigationLink in a list with GroupedListStyle`.the NavigationLink aims to push another View into the master column, using `isDetailLink(false)`struct MasterView : View { var body: some View { List { NavigationLink( destination: EmptyView() ) { Text("show in master") }.isDetailLink(false) } .listStyle(GroupedListStyle()) } }Then you'll surprice yourself:1. in Mac Catalyst, if you click the cell "show in master",the `UINavigationController` will automatically push multiple times and go back to the `MasterVIew`.2. in iOS (iPhone and iPad), if you tap the cell "show in master", and then tap "back",the cell "show in master" will be disabled. No effect when you tap the cell again.
0
0
1.5k
Jan ’20