Skip to Content
The Swift Programming Language

The Swift Programming Language (6.4)

Write safe, fast, expressive code with a modern, general-purpose language.

使用一门现代的通用编程语言,编写安全、快速、富有表现力的代码。

Welcome to Swift 欢迎来到 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 语言参考

Revision History 修订历史

On this page