66 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| ---
 | ||
| title: Swift
 | ||
| localeTitle: 迅速
 | ||
| ---
 | ||
| 
 | ||
| 
 | ||
| # 什么是斯威夫特?
 | ||
| 
 | ||
| Swift是Apple Inc.开发的一种[开源](https://en.wikipedia.org/wiki/Open-source_software)通用编程语言。他们将其描述为:
 | ||
| 
 | ||
| > Swift是一种功能强大且直观的macOS,iOS,watchOS和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日访问。 |