Getting Started with Swift

Source: Internet
Author: User
Tags switch case unpack

I. Simple use 1. Naming Note: Do not use swift-impact compilation, do not use Chinese plus numbers, may cause the project to collapse 2. and OC compared to A.swift's program entrance is the @uiapplicationmainb.oc suffix is. H.M, Swift is. Swiftc.swift is the start of class declaration classes {}--begin at the end of D. To end Swift does not require a semicolon, the end of the  3.SWIFT2.0 enumeration is the beginning of the uppercase letters, swift3.0 is a lowercase beginning of the  4.swift type can be deduced automatically, but for performance, minimize use, you can pass the variable name: Type to specify the type of the variable  5.OC can be operated directly (because it contains implicit conversions); Swift cannot perform implicit conversions, and there are two ways to display transformations   casts: 1. Specify the type of the variable, without using automatic deduction                                   2. Type (type to convert) &nbsp Two. Optional 1. Optional: 1). There is either a value or no value of 2). Option can not be directly calculated, the direct operation of the words need to unpack 2. Concept: Add a question mark (?) after the type of the declared variable/constant. 3. There are 2 ways to unpack: 1) Force unpacking (!) Problem: When the option is not worth it, a crash scenario occurs: When a value is ensured, it can be forced to unpack 2) non-forced unpacking (??): Prevent a crash, set an alternate value   three   conditional statement 1. Curly braces cannot be omitted  2. Three mesh operator can not omit parentheses, easy problem  3.if let new variable name = optional {new variable name scope}  for optional A. Explanation 1). If the option is nil, if false, if not nil, this is true   & nbsp    2). The new variable is named after the unpacked value, and the scope is limited to {} using  b. Multiple optional commas are separated, and the relationship uses the   4.guard let syntax and if let is the opposite Swift2.0 introduced for option A. Explanation 1). If the option is nil, the code inside the parentheses is executed, but not the           2. The new variable is the value after unpacking,  5.if let and guard let selection after the scope {} If code execution is required, use If let and do not want to go down use the guard Let  6.switch case  a.swift is not confined to shaping. String B.break can be omitted when there is an executable statement, the effect and the same C. The default is omitted only if the enumeration is complete, usually omitted   four when enumerating enumerations. String   The string in 1.swift is a struct, and the nsstring  in OC is Object 2. NSString and strings need to be exchanged for each other and cannot be used directly with each other (as)

Getting started with Swift

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.