freeCodeCamp/guide/chinese/swift/index.md

66 lines
2.7 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Swift
localeTitle: 迅速
---
![斯威夫特标志](https://developer.apple.com/assets/elements/icons/swift-playgrounds/swift-playgrounds-64x64_2x.png)
# 什么是斯威夫特?
Swift是Apple Inc.开发的一种[开源](https://en.wikipedia.org/wiki/Open-source_software)通用编程语言。他们将其描述为:
> Swift是一种功能强大且直观的macOSiOSwatchOS和tvOS编程语言。编写Swift代码是交互式和有趣的语法简洁而富有表现力Swift包含开发人员喜爱的现代功能。 Swift代码在设计上是安全的而且还生成快速运行的软件。 1
想立即试用Swift吗 [Repl.it](https://repl.it/languages/swift)为Swift提供在线Read-Eval-Print循环。您将无法访问UIKit或其他常用的API但请试一试
# 基本
要在Swift中声明变量只需使用var后跟变量名称。
```Swift
var x = 6
var name = "Bob"
var boole = true
x = 3
```
常量类似于变量,但它们在创建后不能更改值。
```Swift
let x = 6
let name = "Bob"
let boole = true
```
要将任何内容打印到标准输出只需使用print并将输出放在括号中。
```Swift
let x = "World"
print("Hello ")
print(x)
```
# 版
最新版本是[Swift 4.2](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/RevisionHistory.html) 发布于2018年9月17日.Swift不断发展您可以期待未来有更多变化。建议您在启动新项目时使用最新版本的Swift。
# 文档
Swift记录很多。请记住编写Swift不仅仅涉及到 使用语言还有很多API。学习Swift的最好方法是制作一个 项目或应用程序,无论多小!
* [源代码](https://github.com/apple/swift)
* [开发iOS应用程序Swift](https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/) 想要制作iOS应用程序吗这是一个很好的起点。
* [语言指南](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/) 概述了Swift中的每个功能。如果您在阅读其他人的代码时感到困惑本文档可以为您提供帮助。
# 想了解更多?
* [RayWenderlich.com](https://www.raywenderlich.com/) 有很多很棒的Swift和iOS开发教程。
* [使用Swift进行黑客攻击](https://www.hackingwithswift.com/read) 一个完整的Swift教程使用动手项目将您从初学者带到高级。
### 来源
1. “Swift 4 - 强大的编程语言,也很容易学习。” Apple [developer.apple.com](https://developer.apple.com/swift/) / swift于2017年10月31日访问。