Typecasting now includes as!
About 2 min
Typecasting now includes as! 관련
HACKING WITH SWIFT
What's new in Swift?
Typecasting now includes as! | Changes in Swift 1.2
Typecasting now includes as!
Available from Swift 1.2
From Swift 1.2 onwards we have three ways of performing typecasts: as
is used for typecasts that will always succeed (e.g. someString as NSString
), as?
is used for typecasts that might fail (e.g. someView as? UIImageView
), and as!
is used to force typecasts. If you use as!
and you're wrong, your code will crash.
For example:
let submitButton = vw.viewWithTag(10) as! UIButton
Other changes in Swift 1.2…
The zip() function joins two sequences | Changes in Swift 1.2
The zip() function joins two sequences
The flatMap() method transforms optionals and arrays | Changes in Swift 1.2
The flatMap() method transforms optionals and arrays
Closures can now be marked @noescape | Changes in Swift 1.2
Closures can now be marked @noescape
Classes can now have static methods and properties | Changes in Swift 1.2
Classes can now have static methods and properties
Constants no longer require immediate initialization | Changes in Swift 1.2
Constants no longer require immediate initialization
A new Set data structure | Changes in Swift 1.2
A new Set data structure
Implicit bridging has been reduced | Changes in Swift 1.2
Implicit bridging has been reduced
Multiple if let bindings | Changes in Swift 1.2
Multiple if let bindings