环境(二) – 自定义环境键
环境键的自定义需要两个必要步骤和一个可选步骤: 实现⼀个⾃定义的 EnvironmentKey。 在 EnvironmentValues 上添加扩展,并提供⼀个属性,让我们能在环境中获取和设置该值。 (可选) 在 View 上...
类型(五) – 集合
集合可以看作是无序数组,不能包含重复元素。如果多次添加相同的元素,它只会在集合中出现一次。 检查数组是否包含一个元素的复杂度为 O(n),这意味着 '这取决于数组中有多少个元素'。这是因为 ...
Kana Quest
这个 app 用来学习日语中的平假名(hiragana)与片假名(katakana)。 基本用户界面 这个项目的 assets.zip 压缩文件,包含两个重要的文件: kana.json 文件包含我们要使用的所有日语字符。 Bundle-...
类型(四) – 字典
mapValues mapValues() 的方法更有用,因为它可以让你转换值,并使用原始键将它们放回字典。 let cities = ['Shanghai': 24_256_800, 'Karachi': 23_500_000, 'Beijing': 21_516_000, 'Seoul': ...
批处理(一) – 根据 txt 文件中路径创建目录
根据 foldernamelist.txt 文件中的路径,在当前目录下批量创建文件夹,txt 文件中的内容如下所示: 1. Protocol\1.1 Protocol and Revised Protocols 1. Protocol\1.2. Protocol Signature Page ...
类型(六) – 泛型
func inspect<T>(_ value: T) { print('Received \(type(of: value)) with the value \(value)') } inspect('Haters gonna hate') inspect(56) 限制泛型 func square<T: Numeric>(_...
How to make function parameters isolated 如何隔离函数参数
Any properties and methods that belong to an actor are isolated to that actor, but you can make external functions isolated to an actor if you want. This allows the funct...








