ios-fundamentals
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseiOS Fundamentals Skill
iOS Fundamentals Skill
Build rock-solid foundations for iOS development
为iOS开发打下坚实基础
Learning Objectives
学习目标
By completing this skill, you will:
- Understand iOS app lifecycle and state management
- Master architectural patterns (MVC, MVVM, Clean)
- Implement memory-safe code with ARC
- Use modern Swift concurrency (async/await, actors)
- Apply dependency injection patterns
完成本技能学习后,你将能够:
- 理解iOS应用生命周期与状态管理
- 掌握架构模式(MVC、MVVM、Clean架构)
- 使用ARC实现内存安全的代码
- 运用现代Swift并发编程(async/await、actors)
- 应用依赖注入模式
Prerequisites
前置要求
| Requirement | Level |
|---|---|
| Swift basics | Intermediate |
| Xcode familiarity | Basic |
| OOP concepts | Solid |
| 要求 | 水平 |
|---|---|
| Swift基础 | 中级 |
| 熟悉Xcode | 基础 |
| 面向对象编程概念 | 扎实 |
Curriculum
课程大纲
Module 1: App Lifecycle (4 hours)
模块1:应用生命周期(4小时)
Topics:
- methods
UIApplicationDelegate - for multi-window (iOS 13+)
SceneDelegate - SwiftUI App lifecycle (,
@main)ScenePhase - State transitions: Active → Inactive → Background → Suspended
Code Example:
swift
.onChange(of: scenePhase) { oldPhase, newPhase in
switch newPhase {
case .active: resumeActivities()
case .inactive: pauseActivities()
case .background: saveState()
@unknown default: break
}
}主题:
- 方法
UIApplicationDelegate - 适用于多窗口的(iOS 13及以上)
SceneDelegate - SwiftUI应用生命周期(、
@main)ScenePhase - 状态转换:活跃→非活跃→后台→挂起
代码示例:
swift
.onChange(of: scenePhase) { oldPhase, newPhase in
switch newPhase {
case .active: resumeActivities()
case .inactive: pauseActivities()
case .background: saveState()
@unknown default: break
}
}Module 2: Architecture Patterns (6 hours)
模块2:架构模式(6小时)
Pattern Comparison:
| Pattern | Complexity | Testability | Team Size |
|---|---|---|---|
| MVC | Low | Poor | 1-2 |
| MVVM | Medium | Good | 2-5 |
| Clean/VIP | High | Excellent | 5+ |
模式对比:
| 模式 | 复杂度 | 可测试性 | 团队规模 |
|---|---|---|---|
| MVC | 低 | 差 | 1-2人 |
| MVVM | 中 | 好 | 2-5人 |
| Clean/VIP | 高 | 优秀 | 5人以上 |
Module 3: Memory Management (4 hours)
模块3:内存管理(4小时)
Topics:
- ARC fundamentals
- Weak/unowned references
- Retain cycle prevention
- Instruments profiling
主题:
- ARC基础
- 弱引用/无主引用
- 循环引用预防
- 使用Instruments进行性能分析
Module 4: Swift Concurrency (6 hours)
模块4:Swift并发编程(6小时)
Topics:
- async/await basics
- Task and TaskGroup
- Actors and Sendable
- MainActor for UI
主题:
- async/await基础
- Task与TaskGroup
- Actors与Sendable
- 用于UI的MainActor
Module 5: Dependency Injection (3 hours)
模块5:依赖注入(3小时)
Topics:
- Constructor injection
- Protocol-oriented design
- Testing with mocks
主题:
- 构造器注入
- 面向协议设计
- 使用Mock进行测试
Assessment Criteria
评估标准
| Criteria | Weight |
|---|---|
| Architecture understanding | 30% |
| Memory management | 25% |
| Concurrency implementation | 25% |
| Code quality & patterns | 20% |
| 评估项 | 权重 |
|---|---|
| 架构理解 | 30% |
| 内存管理 | 25% |
| 并发实现 | 25% |
| 代码质量与模式 | 20% |
Skill Validation
技能验证
- State Machine App: Proper lifecycle handling
- MVVM Refactor: Convert MVC to MVVM
- Concurrent Downloader: async/await image loader
- 状态机应用:正确处理生命周期
- MVVM重构:将MVC转换为MVVM
- 并发下载器:基于async/await的图片加载器