Avatar
ジュニア 3/27/2025 3:02 PM
@swift-6.0.3 -swift-version 6 final class NonSendableCounter { var count = 0 nonisolated func increment() async { count += 1 } } // @MainActor func foo() async { let counter = NonSendableCounter() var tasks: [Task<(), Never>] = [] for _ in 0..<10000 { let task = Task { await counter.increment() // NG? } tasks.append(task) } for task in tasks { await task.value } print(counter.count) } await foo()