📜  使用Swift 2进行iOS开发-操场

📅  最后修改于: 2020-12-08 06:38:49             🧑  作者: Mango


在本章中,我们将介绍一个可以编写和执行快速代码的新环境。我们还将涵盖快速操场的以下方面-

  • 变数
  • 辞典
  • 数组
  • 循环
  • 类和对象

注意-我们将仅浏览本教程中将使用的那些基本概念,如果您想深入学习Swift ,可以查看Swift教程

Playground是Xcode附带的用于执行快速代码的工具。我们将从创建一个新的游乐场开始。

启动Swift Playground

要创建一个快速操场,请单击Xcode图标,然后选择第一个选项,开始使用快速操场。

从付款开始

将名称命名为您的游乐场,然后选择“平台”作为iOS。让我们将游乐场命名为演示游乐场。单击下一步。

名称平台

这些是制作游乐场所需要遵循的唯一步骤。以下屏幕截图显示了Playground。

示范游乐场

Sr.No Basic Concepts & Description
1 Variables

A variable is a memory / storage that our program can use to store and manipulate data. Each variable has a specific data type, which determines the size that a variable will occupy in memory.

2 Dictionaries

A dictionary is a collection that stores values in a key value pair, i.e. the data stored in a dictionary is stored in a method where each value is related to a key. Here, every key is unique and cannot appear twice in the same dictionary.

3 Arrays

Arrays are the data types that store the same type of data in an ordered list. The same value can appear at multiple indexes/Places in an array.

4 Loops (Control Flow)

Swift provides a variety of Control Flow Statements. Loops are generally used to iterate over a condition or statement multiple times, until a Condition / Programmer’s need from that loop is satisfied.

5 Classes and Objects

Classes are the general-purpose flexible constructs that are the building blocks of your program’s code.

Object is the term that is generally used to refer to instance of a class, so we can call it instance instead of objects.