Post

Replies

Boosts

Views

Activity

Disable "swipeActions" on only a specific row in a List
Hi, I want to enable swipeActions for some rows of a List while other rows do not have this action. Here is an example: List { ForEach(1..<100) { i in Text("\(i)") .swipeActions(edge: .leading) { Button { total += i } label: { Label("Add \(i)", systemImage: "plus.circle") } .tint(.indigo) } .swipeActions(edge: .trailing) { Button { total -= i } label: { Label("Subtract \(i)", systemImage: "minus.circle") } } } } What would be the best approach to disable the swipeActions for let say the 50 row?
1
0
1.1k
Nov ’23
How to use `HKWorkoutBuilder` inside unit tests on iOS 17 and above
With iOS 17 creation of HKWorkout is deprecated via its init functions and the recommendation is to use HKWorkoutBuilder. If you try to init HKWorkout like you would pre iOS 17 you get this warning of deprecation: The problem is that I am creating this HKWorkout object inside unit tests in order to test a service that works with such objects. And HKWorkoutBuilder requires a HKHealthStore which itself requires to be authenticated to be able to create HKWorkoutActivity instances, like it would be when an app is running. But since the unit tests cannot accept the request on the HKHealthStore I am not sure if using HKWorkoutBuilder inside unit tests is possible. I've also tried to inherit HKHealthStore and override all of its methods, but still, store requires authorization. Any ideas on how to proceed with creating HKWorkout for unit test purposes?
0
1
714
Nov ’23
iOS 17: How to use `HKWorkoutBuilder` inside unit tests
Hi, with iOS 17 creation of HKWorkout is deprecated via its init functions and the recommendation is to use HKWorkoutBuilder: The problem is that I am creating this HKWorkout object inside unit tests in order to test a service that works with such objects. And HKWorkoutBuilder requires a HKHealthStore which itself requires to be authenticated to be able to create HKWorkoutActivity instances, like it would be when an app is running. But since the unit tests cannot accept the request on the HKHealthStore I am not sure if using HKWorkoutBuilder inside unit tests is possible. Any ideas on how to proceed with creating HKWorkout for unit test purposes?
0
2
773
Oct ’23