使用 @Model 宏定义模型
您将使用 @Model 宏来定义所有 SwiftData 模型类。该宏会自动使您的类能够从 SwiftData 加载和存储数据,支持观察更改,并添加 Hashable、Identifiable、Observable 和 PersistentModel 的遵循...
phaseAnimator
一个容器,通过自动循环遍历你提供的一系列阶段来对其内容进行动画处理,每个阶段定义了动画中的一个离散步骤。 具有阶段动画的弹跳 例如,前面展示的表情符号弹跳动画具有两个阶段:向上移动和...
How to call async throwing functions 如何调用异步 throwing 函数
Just like their synchronous counterparts, Swift’s async functions can be throwing or non-throwing depending on how you want them to behave. However, there is a twist: although we ...
What’s the performance cost of calling an async function? 调用 async 函数的性能成本是多少?
Whenever we use await to call an async function, we mark a potential suspension point in our code – we’re acknowledging that it’s entirely possible our function w...
How to call an async function using async let 如何使用 async let 调用 async 函数
Sometimes you want to run several async operations at the same time then wait for their results to come back, and the easiest way to do that is with async let. This lets you start...
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...
What’s the difference between a task and a detached task? 任务和分离任务有什么区别?
If you create a new task using the regular Task initializer, your work starts running immediately and inherits the priority of the caller, any task local values, and its ...
How to control the priority of a task 如何控制任务的优先级
Swift tasks can have a priority attached to them, such as .high or .background, but the priority can also be nil if no specific priority was assigned. This...