The Swift Programming Language (6.4)
Write safe, fast, expressive code with a modern, general-purpose language.
使用一门现代的通用编程语言,编写安全、快速、富有表现力的代码。
Welcome to Swift 欢迎来到 Swift
About Swift · 关于 Swift
Understand the high-level goals of the language.
Version Compatibility · 版本兼容性
Learn what functionality is available in older language modes.
A Swift Tour · Swift 导览
Explore the features and syntax of Swift.
Language Guide 语言指南
The Basics · 基础知识
Work with common kinds of data and write basic syntax.
Basic Operators · 基本运算符
Perform operations like assignment, arithmetic, and comparison.
Strings and Characters · 字符串和字符
Store and manipulate text.
Collection Types · 集合类型
Organize data using arrays, sets, and dictionaries.
Control Flow · 控制流
Structure code with branches, loops, and early exits.
Functions · 函数
Define and call functions, label their arguments, and use their return values.
Closures · 闭包
Group code that executes together, without creating a named function.
Enumerations · 枚举
Model custom types that define a list of possible values.
Structures and Classes · 结构体和类
Model custom types that encapsulate data.
Properties · 属性
Access stored and computed values that are part of an instance or type.
Methods · 方法
Define and call functions that are part of an instance or type.
Subscripts · 下标
Access the elements of a collection.
Inheritance · 继承
Subclass to add or override functionality.
Initialization · 构造过程
Set the initial values for a type's stored properties and perform one-time setup.
Deinitialization · 析构过程
Release resources that require custom cleanup.
Optional Chaining · 可选链式调用(Optional Chaining)
Access members of an optional value without unwrapping.
Error Handling · 错误处理
Respond to and recover from errors.
Concurrency · 并发
Perform asynchronous operations.
Macros · 宏
Use macros to generate code at compile time.
Type Casting · 类型转换
Determine a value's runtime type and give it more specific type information.
Nested Types · 嵌套类型
Define types inside the scope of another type.
Extensions · 扩展
Add functionality to an existing type.
Protocols · 协议
Define requirements that conforming types must implement.
Generics · 泛型
Write code that works for multiple types and specify requirements for those types.
Opaque and Boxed Protocol Types · 不透明类型和封装协议类型
Hide implementation details about a value's type.
Automatic Reference Counting · 自动引用计数
Model the lifetime of objects and their relationships.
Memory Safety · 内存安全
Structure your code to avoid conflicts when accessing memory.
Access Control · 访问控制
Manage the visibility of code by declaration, file, and module.
Advanced Operators · 高级运算符
Define custom operators, perform bitwise operations, and use builder syntax.
Language Reference 语言参考
About the Language Reference · 关于语言参考
Read the notation that the formal grammar uses.
Lexical Structure · 词法结构
Use the lowest-level components of the syntax.
Types · 类型
Use built-in named and compound types.
Expressions · 表达式
Access, modify, and assign values.
Statements · 语句
Group expressions and control the flow of execution.
Declarations · 声明
Introduce types, operators, variables, and other names and constructs.
Attributes · 特性
Add information to declarations and types.
Patterns · 模式
Match and destructure values.
Generic Parameters and Arguments · 泛型形参和实参
Generalize declarations to abstract away concrete types.
Summary of the Grammar · 语法总结
Read the whole formal grammar.