最新发布第10页
排序
如何将 SwiftData 与 iCloud 同步
Xcode配置 如果要将应用程序的数据同步到 iCloud,请转到应用程序Target的 Signing & Capabilities 设置 添加 iCloud 功能 点击 + Capability 按钮,选择 iCloud 功能 选择 CloudKit 在 iCl...
How to create and run a task 如何创建和运行任务
Swift’s Task struct lets us start running some work immediately, and optionally wait for the result to be returned. And it is optional: sometimes you don’t ca...
How to create and use an actor in Swift 如何在 Swift 中创建和使用 actor
Creating and using an actor in Swift takes two steps: create the type using actor rather than class or struct, then use await when accessing its ...
OpenCV 二值化原理
基本流程 通常使用的 JPG、PNG 文件,都是压缩后的格式。这些格式解码之后,可以还原为 RGB 文件。RGB 文件中的每一个像素点都是由 红、绿、蓝三种颜色构成。 RGB 将 RGB 文件中的红色、绿色以...
Kotin 语法
在 Kotlin 中 main 函数是程序的入口,运行 Kotlin 程序的时候,它作为执行的起点。 fun main() { println('Hello Word!') } 注释 Kotlin 的代码注释 /** * 多行注释: * - main 函数是程序的入...
Day 12 – 作用域 Scope
Python 没有块级作用域(Block Scope),只有局部作用域以及全局作用域。 局部作用域 在函数中声明的变量(或函数)具有局部作用域(也称为函数作用域)。它们只能被同一代码块中的其他代码看到...
模型迁移
当你更改数据模型时,SwiftData 可以自动处理模型更新,也可以通过手动干预进行复杂的迁移。 自动处理更新迁移 以下是一些常见的小修改,SwiftData 会自动处理这些模型更新: 添加一个或多个新...
How to store continuations to be resumed later 如何存储要稍后恢复的 continuations
Many of Apple’s frameworks report back success or failure using multiple different delegate callback methods rather than completion handlers, which means a simple continuation won...
How to write basic async tests 如何编写基本的异步测试
Both Swift Testing and XCTest allow us to test asynchronous code built with Swift concurrency by marking tests as async. This means we can wait for concurrent code to complete...
语法(三) – guard
guard 语句的主要用法有以下几种: 提前返回 减少缩进级别 高Happy Path可见性 提前返回 guard 用于提前返回,如果某些先决条件未满足,则退出函数。 func giveAward(to name: String) { guard n...





