环境(一) – 从环境中读取
环境 (environment) 本质上,它是⼀种内置的依赖注⼊ (dependency injection) 技术。 下⾯这个例⼦中,当我们在 VStack 上设置字体时,它会传播到两个 Text 视图中去,并改变它们的外观: Font ...
类型(五) – 集合
集合可以看作是无序数组,不能包含重复元素。如果多次添加相同的元素,它只会在集合中出现一次。 检查数组是否包含一个元素的复杂度为 O(n),这意味着 '这取决于数组中有多少个元素'。这是因为 ...
类型(四) – 字典
mapValues mapValues() 的方法更有用,因为它可以让你转换值,并使用原始键将它们放回字典。 let cities = ['Shanghai': 24_256_800, 'Karachi': 23_500_000, 'Beijing': 21_516_000, 'Seoul': ...
类型(六) – 泛型
func inspect<T>(_ value: T) { print('Received \(type(of: value)) with the value \(value)') } inspect('Haters gonna hate') inspect(56) 限制泛型 func square<T: Numeric>(_...
批处理(一) – 根据 txt 文件中路径创建目录
根据 foldernamelist.txt 文件中的路径,在当前目录下批量创建文件夹,txt 文件中的内容如下所示: 1. Protocol\1.1 Protocol and Revised Protocols 1. Protocol\1.2. Protocol Signature Page ...
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...
What is an asynchronous function?什么是异步函数?
Although Swift functions are synchronous by default, we can make them asynchronous by adding one keyword: async. Inside asynchronous functions, we can call other asy...







