ABI是什麼呢?API你們都知道是應用程序接口 API只是提供函數簽名
而ABI是系統和語言層面的 若是ABI穩定 意味着之後Swift版本更新升級 咱們不須要再修改老版本 Swift 語言編譯的庫了
若是你曾經從Swift 1.x 升級到 Swift 2.x 將會體會頗深php
Fragile binary interface problem是面向對象編程語言的通病 若是在程序中引入了外部庫 咱們的的程序中使用並繼承了該外部庫中的類 若是外部庫有改動 咱們必須從新編譯全部該類的繼承樹 而這類問題被稱爲脆弱的基類 (Fragile base class)git
Swift可被移植到其餘平臺上 github
Swift 2.2已經很好的支持泛型 可是還不夠完善
Swift 3.0開始 將全面支持泛型的全部特性 編程
儘管是一個相對年輕的語言,可是Swift的快速發展已經積累了必定的語言功能 Swift 3.0將會會刪除或改善這些功能 從而提供更好的總體一致性swift
Swift3.0 發佈了新的語言設計規範 其中在Swift3.0中標準庫和核心庫將會遵循這個設計規範
設計規範地址:api
https://swift.org/documentation/api-design-guidelines/
關於設計規範我將會單獨寫一篇博客 感興趣的記得關注個人公衆號(DevTipss)或簡書ruby
在Swift3.0中 currying func 將會被移除 該提案在SE-0002被提出
提案給出的緣由是 currying func 用途是有限的而且增長了語言實現的複雜度app
緣由是var與inout會產生歧義和混亂編程語言
func doSomethingWithVar(var i: Int) { i = 2 // This will NOT have an effect on the caller's Int that was passed, but i can be modified locally } func doSomethingWithInout(inout i: Int) { i = 2 // This will have an effect on the caller's Int that was passed. } doSomethingWithVar(x) print(x) // 1 doSomethingWithInout(&x) print(x) // 2
doSomethingWithVar和doSomethingWithInout均可以在函數內部給i變量賦值 可是doSomethingWithVar並不能真正修改 i 的值
doSomethingWithInout能夠真正修改 i 的值
var就產生了歧義和誤導ide
推薦使用+= 和 -=操做符
舊版autoreleasepool處理錯誤方式:
func doWork() throws -> Result { var result: Result? = nil var error: ErrorProtocol? = nil autoreleasepool { do { ... actual computation which hopefully assigns to result but might not ... } catch let e { error = e } } guard let result = result else { throw error! } return result! }
Swift3.0 autoreleasepool 處理錯誤方式
public func autoreleasepool<Result>(@noescape body: () throws -> Result) rethrows -> Result func doWork() throws -> Result { return try autoreleasepool { ... actual computation which either returns or throws ... } }
enum UITableViewCellStyle : Int { case \`default\` case value1 case value2 case subtitle } enum SCNParticleImageSequenceAnimationMode : Int { case \ `repeat\` case clamp case autoReverse }
在Swift3.0以前咱們引用default和repeat成員時 須要這樣寫:
let cell = UITableViewCell(style: .`default`, reuseIdentifier: nil) particleSystem.imageSequenceAnimationMode = SCNParticleImageSequenceAnimationMode.`repeat`
Swift3.0時 容許咱們直接訪問default repeat 關鍵字成員
let cell = UITableViewCell(style: .default, reuseIdentifier: nil) particleSystem.imageSequenceAnimationMode = SCNParticleImageSequenceAnimationMode.repeat
func f(@noescape fn : () -> ()) {} // declaration attribute //新的語法 func f(fn : @noescape () -> ()) {} // type attribute. func f2(a : @autoclosure () -> ()) {} // type attribute.
__FILE__ -> #file __LINE__ -> #line __COLUMN__ -> #column __FUNCTION__ -> #function __DSO_HANDLE__ -> #dsohandle
Debug 標示符重命名後將會與#available #selector 關鍵字統一風格
參考:https://github.com/apple/swift-evolution