What is the difference between .task() and .onAppear()?
Both run when a view appears, but .task is async and cancelled with the view’s lifetime, while .onAppear is synchronous and does not cancel work for you
Tag
Start from this tag, then add more in the filter bar to narrow further. The URL keeps your choices so you can bookmark or share the same view.
Both run when a view appears, but .task is async and cancelled with the view’s lifetime, while .onAppear is synchronous and does not cancel work for you
Explain why Swift split escaping and non-escaping closures — lifetime, performance, and retain-cycle safety — then cover @autoclosure, trailing syntax, and @Sendable
Distinguish race conditions, data races, priority inversion, deadlock, and actor reentrancy anomalies with short Swift examples and practical fixes
Explain that deinit runs where the last strong reference is released, then connect that rule to UI safety, MainActor isolation, and isolated deinit
Start with the race condition, then compare locks, semaphores, queues, barriers, and actors for protecting shared mutable state in real Swift code
GCD is Apple's low-level API for scheduling work on dispatch queues. OperationQueue is a higher-level Foundation API that represents work as Operation objects with dependencies, cancellation, priorities, and concurrency limits.
Task creates unstructured work that inherits context, Task.detached creates unstructured work without inheriting context, and a task group creates structured child tasks that the parent awaits together.
.async schedules work and returns immediately, while .sync blocks the caller until the work finishes. On the main queue, .async is the normal way to perform UI work, whereas calling .sync from the main thread causes a deadlock.
Compare language-level isolation with traditional queue-based synchronization in production iOS code
Explain when fixed child tasks make async let the better tool, and when dynamic fan-out or incremental result handling pushes you to task groups