The optional default value for 1.var is
Let is no default value
2. Optional Judgment:
The 1> if let system will define a variable to record him, just use it in {}, or you can make continuous judgments using if
For example: if let on = One,let to = two{}
2> using guard to determine optional options
The variable u defined by the guard let u= URL else{return} can be used outside of {}
3> Note: If let cannot be associated with | | $$ and other conditions, use where you can use | | &&
4> the benefit of using guard is to omit a layer of nesting
3.switch can be judged for any data type, no longer limited to integers, must be added to the default
4.swift inside the definition string is a struct
5. Calculate the length of the string using Str.characters.count
Calculates the length of a string in the UTF8 format
Str.utf8.count
Calculates the number of bytes under the encoding format
Str.lenthofbyteuseingencodeing (encoded format)
6. Traversing a string
For C in Str.characters
7. Concatenation of strings
Let name:string = "Lao Wang"
Let age = 18
1>let str = "I call" + name + "age" + \ (Ages)
2>let str 1 = "My name \ (name) Age \"
8. Print the specified format:
1>let r1 = String (format: "%02d:%02d:%02d", Arguments:[h,m,s])
2>let r2 = String (format: "02d:%02d:%02d", H,m,s)
9. Interception of strings
Let R1 = Str.substringfromindex ("ss". EndIndex)
Advanced advance (left-to-right integer inverse negative)
Seamless conversion of 10.swift to OC
Str as nsstring, you can use the method inside OC
The 11.swift array can be used to add basic data types.
Let array = [1,3,3,4,5]
12. Dictionary merging can use +, but note that the dictionary is of the same type
13. Define an empty array
Let arr: [nsobject] = [NSObject] ()
14. Merging of dictionaries cannot be used + manual traversal is required to add
No keys are added, some values are replaced
Summary of Swift Basic grammar simple knowledge points