1. Function permissions
- Public: Maximum permissions that can be accessed in the current framework and other frameworks
Internal: Default permissions that can be accessed freely in the current framework
Private: Personal permissions, accessible only in the current file
The development of the proposed strict control permissions, do not want to let others access things must be private2 、?? operator
- ?? Used to determine if the preceding parameter is nil, and if it is nil, return?? After the data, if not nil then?? The following statement does not execute
- var string:string? = Nil
Let title = string?? "String = nil"
Print (title)//String = Nil
String = "String! = nil"
Let Title1 = string?? "String = nil"
Print (Title1)//String! = Nil
3. Type conversion as! As?
- as! The forced format of a type conversion, if it can be converted, returns an object that has been converted, and a run-time error is thrown when it cannot be converted. Therefore, you should not use as! unless you are absolutely sure that you can convert To perform a forced type conversion.
- As? Returns an optional type of the converted type, if the conversion succeeds in returning an optional value, otherwise the optional value is nil, and because it is an optional type, it is recommended to use this method for type conversion, even if the conversion fails.
Swift some syntax