Shared Mutable State In Task (ARCH9038)
هذا المحتوى غير متوفر بلغتك بعد.
Key swift.async.shared-mutable-state-in-task · Severity warning · Category async
Flags static / global vars mutated inside Task, DispatchQueue or Thread closures without an actor or lock.
Incorrect
Section titled “Incorrect”static var hits = 0Task { hits += 1 }Correct
Section titled “Correct”actor Counter { var hits = 0; func hit() { hits += 1 } }Move the state into an actor, or guard it with a lock / serial queue.