XuX-Stewed Noodles 资源-第4页
XuX的头像-Stewed Noodles 资源
超级管理员河南管理员超级版主
一拳之石取其了坚,一勺之水取其净!
环境(一) - 从环境中读取-Stewed Noodles 资源

环境(一) – 从环境中读取

环境 (environment) 本质上,它是⼀种内置的依赖注⼊ (dependency injection) 技术。 下⾯这个例⼦中,当我们在 VStack 上设置字体时,它会传播到两个 Text 视图中去,并改变它们的外观: Font ...
类型(五) - 集合-Stewed Noodles 资源

类型(五) – 集合

集合可以看作是无序数组,不能包含重复元素。如果多次添加相同的元素,它只会在集合中出现一次。 检查数组是否包含一个元素的复杂度为 O(n),这意味着 '这取决于数组中有多少个元素'。这是因为 ...
2年前
0749
轻松解析 XML-Stewed Noodles 资源

轻松解析 XML

开始解析 首先,我们将创建两个类来保存所有数据:一个名为 XMLNode 的类代表解析 XML 中的一个节点,另一个名为 MicroDOM 的类负责将 XML 实际解析为节点。XML 的本质是整个树最终由一个根节点...
2年前
07214
错误-Stewed Noodles 资源

错误

错误基础知识 所有要抛出的错误都必须是符合Error协议的枚举。 enum PasswordError: Error { case empty case short } 错误可以添加关联值 enum PasswordError: Error { case empty case short ...
2年前
0728
类型(四) - 字典-Stewed Noodles 资源

类型(四) – 字典

mapValues mapValues() 的方法更有用,因为它可以让你转换值,并使用原始键将它们放回字典。 let cities = ['Shanghai': 24_256_800, 'Karachi': 23_500_000, 'Beijing': 21_516_000, 'Seoul': ...
2年前
0717
类型(六) - 泛型-Stewed Noodles 资源

类型(六) – 泛型

func inspect<T>(_ value: T) { print('Received \(type(of: value)) with the value \(value)') } inspect('Haters gonna hate') inspect(56) 限制泛型 func square<T: Numeric>(_...
2年前
07110
批处理(一) – 根据 txt 文件中路径创建目录-Stewed Noodles 资源

批处理(一) – 根据 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 如何隔离函数参数-Stewed Noodles 资源

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...
引用类型和值类型-Stewed Noodles 资源

引用类型和值类型

两者区别 布尔、数字、字符串、数组、字典、结构体等都是 Swift 中的值类型。类是引用类型,闭包也是引用类型。 引用类型在分配时是共享的,指向同一条数据,可以有多个所有者;值在分配时是复...
2年前
0695
What is an asynchronous function?什么是异步函数?-Stewed Noodles 资源

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...