Attack on Swift-------variable, constant

Source: Internet
Author: User

Source file extension for 1.Swift. Swift

2. Two not required: ① do not need to write the main function ② no need to add a semicolon after each statement

3. Multi-line annotations can be nested

4.let declaring a constant VAR declaration variable

Let radius = 10

var x= 0,y = 0,z = 0

5.UIImageView

var ImageView = Uiimageview ()

Imageview.image = UIImage (name: "002.png")

Imageview.frame = CGRectMake (20,20,100,50)

Self.view.addSubview (ImageView)

6.Playground

7. String

①: General form

Let Web = "xxxxxxx"

②: Stitching plus +

Let str = "123"

Let str2 = "456"

Let dest = str + str2

③: Interpolation

Let hand = 2

var age = 20

Let str = "I am (age) year old, have \ (hand) only Hand"

④: Type Conversion

var age = 10

Convert to string: <1>var str = string (age) <2>var str2 = "\ (age)"

8: Print Output function

PRINTLN: Output will be wrapped automatically

Print: Less line wrapping

code example: ①println ("Learn Swift") ②let name = "Learn Swift + learn x\n"; Print (name)

9: Names of constants and variables

Any..... (Control + COMMAND + space-----Pop-up emoji keyboard)

Attention:

Attack on Swift-------variable, constant

Related Article

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.