logo资料库

Swift 5.1官方中文版.pdf

第1页 / 共377页
第2页 / 共377页
第3页 / 共377页
第4页 / 共377页
第5页 / 共377页
第6页 / 共377页
第7页 / 共377页
第8页 / 共377页
资料共377页,剩余部分请下载后查看
Swift iOS, macOS, watchOS tvOS C Objective-C Swift Swift C Objective-C Int Double Float Bool String Swift Array Set Dictionary C Swift Swift C Swift Swift Objective-C Tuple Swift Optional “ x ” “” Objective-C nil Objective-C nil Swift Swift Swift String Int String String maximumNumberOfLoginAttempts welcomeMessage
10 "Hello" let var 1 2 let maximumNumberOfLoginAttempts = 10 var currentLoginAttempt = 0 “ maximumNumberOfLoginAttempts 10 currentLoginAttempt 0 ” var x = 0.0, y = 0.0, z = 0.0 let type annotation welcomeMessage String
var welcomeMessage: String “...” “ String welcomeMessage ” “ String ”“ String ” welcomeMessage welcomeMessage = "Hello" var red, green, blue: Double Swift welcomeMessage welcomeMessage Unicode 1 2 3 let π = 3.14159 let = "" let = "dogcow" Unicode
Swift ` friendlyWelcome "Hello!" "Bonjour!" : 1 2 3 var friendlyWelcome = "Hello!" friendlyWelcome = "Bonjour!" // friendlyWelcome "Bonjour!" 1 2 3 let languageName = "Swift" languageName = "Swift++" // - languageName print(_:separator:terminator:) : 1 2 print(friendlyWelcome) // “Bonjour!” print(_:separator:terminator:) Xcode print(_:separator:terminator:) “console” separator terminator
terminator -- print(someValue, terminator:"") Swift string interpolation Swift 1 2 print("The current value of friendlyWelcome is \(friendlyWelcome)") // “The current value of friendlyWelcome is Bonjour!” Swift Swift C // : // /* */ : 1 2 /* */ C Swift
1 2 3 /* /* */ */ Swift ; 1 2 let cat = " // “ ” "; print(cat) 42 -23 Swift 8163264 C 8 UInt8 32 Int32 Swift min max 1 2 let minValue = UInt8.min // minValue 0 UInt8 let maxValue = UInt8.max // maxValue 255 UInt8
min max UInt8, UInt8 Int Swift Int 32 Int Int32 64 Int Int64 Int 32 Int -2,147,483,648 ~ 2,147,483,647 UInt Swift UInt 32 UInt UInt32 64 UInt UInt64 UInt Int Int 3.14159 0.1 -273.15 Int Swift
Double 64 Float 32 Double 15 Float 6 Double Swift type safe String Int Swift type checks Swift type inference C Objective-C Swift literal value literal 42 3.14159 42 Swift Int 1 2 let meaningOfLife = 42 // meaningOfLife Int
分享到:
收藏