本文共 1734 字,大约阅读时间需要 5 分钟。
斯威夫特山地车
Swift is a language that is used to create an application for the iOS software included in Apple products. It was derived from the objective C and is an Object Oriented programming language. Let us start with the basic program of Swift i.e. Hello World.
Swift是一种语言,用于为Apple产品中包含的iOS软件创建应用程序。 它源自目标C,是一种面向对象的编程语言。 让我们从Swift的基本程序即Hello World开始 。
This program will give you an idea of the syntax and how we can display the output on the screen. Like any other language, Swift also has a software i.e. XCode, where the program is run and commands are executed.
该程序将为您提供语法概念以及如何在屏幕上显示输出。 像任何其他语言一样,Swift也有一个软件,即XCode ,可以在其中运行程序并执行命令。
Open XCode terminal and type the following program
打开XCode终端并键入以下程序
import Foundationprint("Hello, World!");
Hit enter key to run the program and the output will be shown.
按Enter键运行程序,将显示输出。
Output
输出量
Hello, World!
Screenshot with code and the output i.e. Xcode terminal
屏幕截图,带代码和输出,即Xcode终端
Explanation:
说明:
Here, printf function is used to show the text quoted in " " on the output screen as in C.
在这里, printf函数用于在输出屏幕上像C一样显示在“”中引用的文本。
Semicolon ";" is the must after every end of the command as similar in C/C++ etc.
分号“;” 与C / C ++等类似,是命令每一行之后的必需内容。
// is used to comment in a program as depicted above.
//用于在程序中如上所述进行注释。
import Foundation is a library which is used to access all the functions present that header file.
import Foundation是一个库,用于访问该头文件中提供的所有功能。
There can be many such header files that can be imported.
可以导入许多此类头文件。
Whereas, "program ended with exit code: 0" at the end shows that there are no further programs to be run.
而结尾处的“程序以退出代码0结尾”表示没有其他程序要运行。
Stay connected with us to know more about Swift coding in our further tutorials.
与我们保持联系,以在进一步的教程中进一步了解Swift编码。
翻译自:
斯威夫特山地车
转载地址:http://pcvzd.baihongyu.com/