ABI是什么呢?API大家都知道是应用程序接口 API只是提供函数签名 而ABI是系统和语言层面的 如果ABI稳定 意味着以后Swift版本更新升级 我们不需要再修改老版本 Swift 语言编译的库了 如果你曾经从Swift 1.x 升级到 Swift 2.x 将会体会颇深
Fragile binary interface problem是面向对象编程语言的通病 如果在程序中引入了外部库 我们的的程序中使用并继承了该外部库中的类 如果外部库有改动 我们必须重新编译所有该类的继承树 而这类问题被称为脆弱的基类 (Fragile base class)
Swift可被移植到其他平台上
Swift 2.2已经很好的支持泛型 但是还不够完善 Swift 3.0开始 将全面支持泛型的所有特性
尽管是一个相对年轻的语言,但是Swift的快速发展已经积累了一定的语言功能 Swift 3.0将会会删除或改善这些功能 从而提供更好的整体一致性
Swift3.0 发布了新的语言设计规范 其中在Swift3.0中标准库和核心库将会遵循这个设计规范 设计规范地址:
https://swift.org/documentation/api-design-guidelines/
关于设计规范我将会单独写一篇博客 感兴趣的记得关注我的公众号(DevTipss)或简书
在Swift3.0中 currying func 将会被移除 该提案在SE-0002被提出 提案给出的原因是 currying func 用途是有限的并且增加了语言实现的复杂度
原因是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) // 1doSomethingWithInout(&x)
print(x) // 2
doSomethingWithVar和doSomethingWithInout都可以在函数内部给i变量赋值 但是doSomethingWithVar并不能真正修改 i 的值 doSomethingWithInout可以真正修改 i 的值 var就产生了歧义和误导
推荐使用+= 和 -=操作符
旧版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
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有