STAGE 6

iOS 동시성 & 성능 최적화

부드럽고 빠른 앱을 만드는 데 필요한 동시성, 렌더링 최적화, Combine 학습 레포

GitHub Repository

학습 주제

01. Thread Basics

Process vs Thread, RunLoop, Race Condition

동시성

02. GCD

DispatchQueue, sync/async, serial/concurrent, DispatchGroup, Semaphore

동시성

03. async/await

async/await, Task, async let, withCheckedContinuation

동시성

04. Actor

Actor, MainActor, Sendable — 컴파일러 수준 Data Race 방지

동시성

05. Rendering

SwiftUI diff, Equatable, identity/lifetime/dependency

렌더링

06. Image Optimization

ImageIO 다운샘플링 (48MB → 0.04MB), NSCache, Prefetching

렌더링

07. Combine

Publisher, Subscriber, debounce, combineLatest, flatMap

Combine

Before / After

// ❌ Before — 퍼플 경고, 크래시 가능
URLSession.shared.dataTask(with: url) { data, _, _ in
    self.imageView.image = UIImage(data: data!) // 백그라운드 스레드!
}.resume()

// ✅ After — async/await + @MainActor
func loadImage() async throws {
    let (data, _) = try await URLSession.shared.data(from: url)
    await MainActor.run {
        self.imageView.image = UIImage(data: data)
    }
}
// ❌ Before — 48MB
let image = UIImage(data: try! Data(contentsOf: url))

// ✅ After — 0.04MB (1200배 절약)
let image = downsample(imageAt: url, to: CGSize(width: 100, height: 100))

이 단계를 마치면