I have a swift package with a function that formats a HKQuantity using the current locale. I want to write a unit test with all locales the package is localized for. I do not want to insert a separate locale parameter, I want to test the function with the current locale as I use the function only with the current locale.
Can I set the current locale for this use case in the code somehow?
Example:
do {
let quantity = HKQuantity(unit: unit, doubleValue: 0.955)
let result = quantity.formattedAsOxygenSaturation(precision: .better)
let expectedResult = "95.5 %"
XCTAssertEqual(result, expectedResult)
}
Thanks!
Post
Replies
Boosts
Views
Activity
I would like to initialize a HKDeletedObject for an unit test. Before diving into NSCoder: Has somebody done this before and can give some advice? Thanks in advance!
How to hide keyboard on tap outside of TextField in SwiftUI?
SwiftUI on iOS 16
Within a List a Section with a TextField
I want to dismiss the keyboard if I tap outside the focused TextField.
I thought, searched and found no solution the does this correctly. Either it does not dismiss in all cases or it does dismiss while clicking into the TextField, too.
What is the best or a good solution for this problem?
I have an app with Core Data with CloudKit. I want to use a unique element among other non-unique elements in that sense that it should be there after installation of an app, but it should be there only once on all devices. Not one separate for each device, it should be the same on all devices.
As I do not know whether the app was already installed on another device and maybe not synchronized to iCloud, what would be the best practice to handle such unique elements?