Post

Replies

Boosts

Views

Activity

Reply to JSONEncoder: How to sort keys using "localizedStandardCompare"? (just like how Xcode 16 serialize a xcstrings file)
@DTS Engineer @Developer Tools Engineer Thank you for your fast response and detailed information! ❤️ After further investigation, I found the implementation of JSONSerialization seems to be incorrect. When using .sortedKeys options with JSONSerialization, the keys are always sorted in the "Finder-like" order instead of lexicographic order. This is inconsistent with the documentation. But I'm not sure what is the expected behavior. I can reproduce this issue with Xcode 16.0 on the latest macOS 15.0 and iOS 18.0. I've submitted a feedback FB15177571.
Sep ’24
Reply to New Swiftui Text timer not counting down
Text(.now, format:.timer(countingDownIn: Date.now..<Date.now.addingTimeInterval(120), showsHours: true, maxFieldCount: 2, maxPrecision: .seconds(60)) ) Using Date.now here confused me 🤔. The first argument .now will be evaluated when the view body is updated, in a very unpredictable way. The text will stay on the last view update time. I think this new API should be used in this way: @State private var date: Date = .now var body: some View { Text(date, format: .timer(...)) .onReceive(Timer.publish(/* on every seconds */)) { date = $0 } } UPDATE: Found: https://developer.apple.com/documentation/swiftui/timedatasource/currentdate Simply change Date.now to TimeDataSource<Date>.currentDate.
Aug ’24