Import UIKitclass Person: NSObject {var name: String? { // can give newvalue a custom name willset (new) { //The property is about to change and the method that is called when it is not changed // In this method there is a default system attribute
First, Swift basic operation
Import FrameOC is #import Swift is import UIKit
Swift definition Identifiers: Constants or variables must be specified
VAR (variable)/let (constant) identifier name: type of identifier =
Official website: http://snapkit.io/Github:https://github.com/snapkit/snapkitSnapkit is a DSL-to-make Auto-Layout easy on both IOS and OS x.
Simple & Expressive Chaining DSL allows building constraints with minimal amounts of code while
Swift-Add Pure AlamofireIf you have a neat code and can't tolerate any extra stuff, keep looking down.1. Download alamofire (https://github.com/Alamofire/Alamofire)2. Unzip and open alamofire.xcworkspace3. Delete unnecessary content (depending on
Optional type * Optional type indicates that a variable can have a value or no value * C and objective-C do not have an optional type concept * Only optional types in Swift can be assigned nil* If you declare an optional constant or variable but are
Defined
letDefines constants that are not allowed to be modified once assigned
varDefine variables that can still be modified after assignment
//: # 常量//: 定义常量并且直接设置数值let x = 20//: 常量数值一经设置,不能修改,以下代码会报错// x = 30//: 使用 `:
In OBJC you can't put a non-object type into an array, you have to "Marshal" it and then put it in the array.In Swift you can easily put non-object types into an array:let ary = [1,2,3]You can explicitly specify the element type:let ary:[Int] = [1,2,
Sorting algorithms are often used, such as: bubbling, selection, quick sorting, binary insertion sorting, and so on. The front two does not say, paste out their own quick sort and binary insert sort of swift and Java code implementation, like the
Object-oriented general overview: Swift is not only capable of process-oriented programming, but also object-oriented programming (OOP). Object-oriented is actually "taking the object as the core", thinking that our objective world is composed of
1. Functions1.1 Func Funcnmae () {} This defines a function whose arguments are null, the return value is NULL, and if the parameters and return values are written directly in two brackets.The 1.2 parameter needs to indicate the type, and if no
Defining enumeration methods an enum Season {//Each case defines an instance of the Spring cases Summer-Fall-the-winter}//definition enumeration mode two enum WEEKDA Y {//Use a case to list all enumerated instances cases Monday, Tuesday, Wednesday,
You know that Swift has arithmetic operators similar to C,OBJC, which are:+-*/%But you may not know that there is a big difference between the operators in Swift and the C,OBJC language that they cannot be "spilled", either overflow or underflow!In
Arc4random () This global function generates a 9-digit random integer1, the following is the use of the Arc4random function to find a 1~100 random number (including 1 and 100)Let Temp:int = Int (arc4random ()%) +1 Print (temp)2, the following
Selectable options to determine
Because the optional content may be nil , and once is nil not allowed to participate in the calculation
therefore, in use, it is often necessary to determine whether the content of an option isnil
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