最新发布第25页
Docker 容器与主机间文件/文件夹拷贝-Stewed Noodles 资源

Docker 容器与主机间文件/文件夹拷贝

Docker 容器与主机之间文件或者文件夹的拷贝是经常遇到的场景。Docker 提供了docker up 命令,可以轻松实现容器与主机之间文件或者文件夹的拷贝。docker cp命令语法docker cp命令的基本语法,如...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri2年前
0180
使用 @Model 宏定义模型-Stewed Noodles 资源

使用 @Model 宏定义模型

您将使用 @Model 宏来定义所有 SwiftData 模型类。该宏会自动使您的类能够从 SwiftData 加载和存储数据,支持观察更改,并添加 Hashable、Identifiable、Observable 和 PersistentModel 的遵循...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri1年前
0180
更新数据-Stewed Noodles 资源

更新数据

在 SwiftData 中更新数据非常简单,默认情况会自动保存,无需手动调用保存操作。以下示例演示了创建一个 Student模型,并获取模型的数据进行更新,数据将自动保存: @Model class Student { var...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri1年前
0180
删除数据-Stewed Noodles 资源

删除数据

删除 SwiftData 对象需要两个步骤:首先在你的模型上下文上调用 delete()方法,并传入你想要删除的对象;然后保存更改,可以通过显式调用 save(),或者如果启用了自动保存,则等待自动保存触发...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri1年前
0180
How to call an async function using async let 如何使用 async let 调用 async 函数-Stewed Noodles 资源

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...
Why can’t we call async functions using async var? 为什么我们不能使用 async var 调用 async 函数?-Stewed Noodles 资源

Why can’t we call async functions using async var? 为什么我们不能使用 async var 调用 async 函数?

Swift’s async let syntax provides short, helpful syntax for running lots of work concurrently, allowing us to wait for them all later on. However, it only works as ...
How to fix the error “async call in a function that does not support concurrency” 如何修复错误 “async call in a function that does not support concurrency”-Stewed Noodles 资源

How to fix the error “async call in a function that does not support concurrency” 如何修复错误 “async call in a function that does not support concurrency”

This error occurs when you’ve tried to call an async function from a synchronous function, which is not allowed in Swift – asynchronous functions must be able to suspend the...
How to create a custom AsyncSequence 如何创建自定义 AsyncSequence-Stewed Noodles 资源

How to create a custom AsyncSequence 如何创建自定义 AsyncSequence

There are only three differences between creating an AsyncSequence and creating a regular Sequence, none of which are complicated.创建 AsyncSequence 和创建...
What are tasks and task groups? 什么是任务和任务组?-Stewed Noodles 资源

What are tasks and task groups? 什么是任务和任务组?

Using async/await in Swift allows us to write asynchronous code that is easy to read and understand, but by itself it doesn’t enable us to run anything concurrently – even w...
How to make a task sleep 如何使任务进入休眠状态-Stewed Noodles 资源

How to make a task sleep 如何使任务进入休眠状态

Swift’s Task struct has a static sleep() method that will cause the current task to be suspended for a set period of time. You need to call Task.sleep()&n...