This is probably very rare bug. I used the onMove modifier to ForEach to create a UI that can sort the list. By using the onMove modifier, sorting implementation is easy and vibration is applied when dragging. This is very useful.
However, after about 15 seconds of continuous dragging, the following error logs are dump and the vibration stops. This is probably a bug.
2022-06-14 16:53:17.433135+0900 ListSortTest[619:24974] [hapi] CHHapticEngine.mm:1831 -[CHHapticEngine(CHHapticEngineInternal) getAvailableChannel:]: ERROR: Unable to add an additional player channel
2022-06-14 16:53:17.433533+0900 ListSortTest[619:24974] [Feedback] failed to create player with pattern for <_UIFeedbackCoreHapticsHapticsOnlyEngine: 0x280265110>: Error Domain=com.apple.CoreHaptics Code=-10851 “(null)”
2022-06-14 16:53:17.467165+0900 ListSortTest[619:24974] [hapi] CHHapticEngine.mm:1831 -[CHHapticEngine(CHHapticEngineInternal) getAvailableChannel:]: ERROR: Unable to add an additional player channel
2022-06-14 16:53:17.467297+0900 ListSortTest[619:24974] [Feedback] failed to create player with pattern for <_UIFeedbackCoreHapticsHapticsOnlyEngine: 0x280265110>: Error Domain=com.apple.CoreHaptics Code=-10851 “(null)”
2022-06-14 16:53:17.500289+0900 ListSortTest[619:24972] [hapi] CHHapticEngine.mm:1831 -[CHHapticEngine(CHHapticEngineInternal) getAvailableChannel:]: ERROR: Unable to add an additional player channel
2022-06-14 16:53:17.500480+0900 ListSortTest[619:24972] [Feedback] failed to create player with pattern for <_UIFeedbackCoreHapticsHapticsOnlyEngine: 0x280265110>: Error Domain=com.apple.CoreHaptics Code=-10851 “(null)”
Example:
struct ContentView: View {
@State private var numbers: [Int] = [1, 2, 3, 4, 5]
var body: some View {
VStack {
List {
ForEach(numbers, id: \.self) { number in
Text(String(number))
}
.onMove(perform: moveRow)
}
EditButton()
.padding()
}
}
private func moveRow(from source: IndexSet, to destination: Int) {
numbers.move(fromOffsets: source, toOffset: destination)
}
}