iOS Development Swift Chapter-Brief introduction

Source: Internet
Author: User

iOS Development Swift Chapter-Brief introduction

First, Introduction

Swift is Apple's new programming language released in 2014 by WWDC (Apple Developer Conference)

Swift in the Chinese translation of the "Swift", is its logo is a swallow, like objective-c, can be used to develop iOS, Mac applications

Apple has been designing the Swift language since July 2010 and it takes 4 years to build

Swift's grammatical features

You can see the shadow of Objective-c, JavaScript, Python and other languages from its syntax.

Simple syntax, concise code, easy to use

Can be mixed with objective-c (call each other)

Why design the Swift language?

Make application development easier, faster, and more stable

Ensure better quality for final applications

Ii. Comparison of programming languages

Scripting languages (such as Python)

Usually easy to write and test without having to go through compilation-link-run three tedious steps

But not very powerful and difficult to bring high quality programs

If you want to write a game that takes full advantage of the performance of your device, then this language is not ideal

Traditional programming languages (e.g. OBJECTIVE-C)

Enables developers to better leverage device performance and develop more complex applications

But it's usually harder to master and more cumbersome to compile and test (experience compilation-link-run three steps)

Swift

Draw on the advantages of objective-c, JavaScript, Python, and other languages

Goal: Simple, efficient, powerful

Third, relevant data

The Xcode version must be >= 6.0 to use Swift for debugging and development

Swift has been a developer's concern since its release, with 1 days of Xcode 6 beta downloads exceeding 14 million times

Official e-book "The Swift Programming Language" Download volume exceeded 370,000 times

A foreign developer has implemented the Flappy Bird game with Swift (the developer has only 4 hours to get started with swift, programming plus rest time, close to 9 hours)

Iv. Grammar

1.2 Not required

(1) You do not need to write the main function: the code in the global scope is automatically used as the entry point of the program (from the top down)

(2) You do not need to add a semicolon let radius = 10 after each statement

If you like, you can also add let radius = 10;

There is a case where a semicolon must be added: let radius = 10 when there are multiple statements on the same line of code; Let Radius2 = 15

2. Notes

Single line comment//This is a single line comment

Multiline Comment/* This is a multiline comment */

Unlike other languages, Swift's multiline comments can be nested in multiple lines of comments/* haha/hehe */haha */

V. Constants and variables

How do I declare constants and variables?

Declare a constant let radius = 10

var to declare variable var age = 20

var x = 0.0, y = 0.0, z = 0.0

Named:

You can basically use any character you like as a constant and variable name.

letπ= 3.14159

Let URL = "http://www.cnblogs.com/asd5551680/

Let???? = "Dogcow"//?? And?? is a special type of Unicode character

Note points for constants and variable names

Cannot contain mathematical symbols (such as + and *)

Cannot contain arrows (e.g. ↑, ↓, ←, →)

Cannot contain illegal invalid Unicode characters (for example?). ♠

cannot be a keyword (such as Let, Var)

Cannot contain horizontal lines –, tabs (e.g. My–name)

Cannot start with a number (e.g. 123go)

Cannot be a single underscore _ (e.g. var _ = 10)

iOS Development Swift Chapter-Brief introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.