Swift is an open source programming language that supports multiple programming paradigms and compiled. It was released by Apple at WWDC (Apple Developer Conference) in 2014 and is used to develop iOS, OS X and watchOS applications.

Swift combines the best of C and Objective-C without the limitations of C compatibility.

Swift can use the same running environment as Objective-C on Mac OS and iOS platforms.

Swift optional types syntax

Swift's Optional type, used to handle missing values. Optional means "there is a value there and it is equal to x" or "there is no value there".

Swift optional types example

import Cocoa
var myString:String? = nil
if myString != nil {
    print(myString)}else{
    print("字符串为 nil")}