標籤:possible post object rod equal ant ble clu status
一、資料類型
1、基礎類型的封裝
Swift provides its own versions of all fundamental C and Objective-C types, including Int
for integers, Double
and Float
for floating-point values
2、新類型
Swift introduces advanced types not found in Objective-C, such as tuples.
Tuples enable you to create and pass around groupings of values.
3、型別安全語言
Swift is a type-safe language, which means the language helps you to be clear about the types of values your code can work with.
4、資料類型轉化
let three = 3
let pointOneFourOneFiveNine = 0.14159
let pi = Double(three) + pointOneFourOneFiveNine
// pi equals 3.14159, and is inferred to be of type Double
5、Tuples
let http404Error = (404, "Not Found")
let (statusCode, statusMessage) = http404Error
print("The status code is \(statusCode)")
// Prints "The status code is 404"
print("The status message is \(statusMessage)")
// Prints "The status message is Not Found"
6、Optionals
let possibleNumber = "123"
let convertedNumber = Int(possibleNumber)
類型推斷 convertedNumber:Int?
7、Optional Binding
You use optional binding to find out whether an optional contains a value
8、Implicitly Unwrapped Optionals
. You write an implicitly unwrapped optional by placing an exclamation mark (String!
) rather than a question mark (String?
) after the type that you want to make optional.
swift語言點評二