最新发布第22页
排序
Hilt 框架
Hilt 是 Google 官方推荐的 Android 依赖注入(DI)框架,基于 Dagger,极大简化了配置和使用成本,减少样板代码,与 ViewModel / Activity / Fragment / Service 深度集成,可以自动管理依赖生...
Day 7 – 猜单词游戏
猜单词游戏的基本业务流程如下所示 生成单词,检测答案 生成随机单词,并检测用户输入的单词是否在选定的单词中 import random word_list = ['aardvark', 'baboon', 'camel'] chosen_word = ran...
查询数据
SwiftData 提供了 @Query 宏,用于从 SwiftUI 视图中查询模型对象,并可选择提供排序顺序、过滤谓词,以及用于平滑处理结果变化的自定义动画或自定义事务。更棒的是,@Query 会在每次数据变化时...
What’s the difference between await and async let? await 和 async let 有什么区别?
Swift lets us perform async operations using both await and async let, but although they both run some async code they don’t quite run the same: await wai...
How to manipulate an AsyncSequence using map(), filter(), and more 如何使用 map()、filter() 等作 AsyncSequence
AsyncSequence has implementations of many of the same methods that come with Sequence, but how they operate varies: some return a single value that fulfills you...
How to create and use task local values 如何创建和使用任务本地值
Swift lets us attach metadata to a task using task-local values, which are small pieces of information that any code inside a task can read.Swift 允许我们使用 task-local ...
How to handle concurrency errors in unit tests 如何处理单元测试中的并发错误
Both Swift Testing and XCTest give us three main options for handling errors in tests: we can consider them immediate failures, we can handle them internally and make our own asser...
Live Data
基本介绍 LiveData 是一个可观察的数据持有类。与普通的可观察对象不同,LiveData 具备生命周期感知能力,也就是说它会遵循应用中其他组件(如 Activity、Fragment 或 Service)的生命周期。 这...






