Post

Replies

Boosts

Views

Activity

How to make a unit test in a swift package with different current locales?
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!
1
0
758
Nov ’23
How to hide keyboard on tap outside of TextField in SwiftUI?
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?
2
1
1.6k
Dec ’22
How to make a unit test in a swift package with different current locales?
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!
Replies
1
Boosts
0
Views
758
Activity
Nov ’23
How to hide keyboard on tap outside of TextField in SwiftUI?
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?
Replies
2
Boosts
1
Views
1.6k
Activity
Dec ’22