其他
相对于Swift3.0以下的版本,Swift3.0的改变可以参考如下链接(我就不一一细说了):Swift3.0的改变(Swift对Swift)
进入主题
下面我就说一说相对我之前用的OC语法来说 ,Swift3.0的改变,具体如下:
1. OC中通过 [类名 class] 直接获取类名,Swift3.0中是: 类名.classForCoder() 或者 类名.self 获取类名。

下面是Swift3.0中获取方法

2. OC中是使用 imageWithRenderingMode: 方法禁止系统渲染tabBarItem的图片,而在Swift3.0中是: withRenderingMode


3.在Swift中是没有预编译命令的,所以就是没有宏定义(macro)的概念。但是可以通过使用属性或者函数来达到宏定义的作用。
通过属性达到宏定义的代替作用

通过函数达到宏定义的代替作用

4. Swift3.0中通过使用 deinit{} 方法代替 -(void)dealloc{}
5.0 Swift3.0中通过使用 // MARK: 注释说明文字 来代替OC中的 #pragma mark 注释说明文字;通过使用 // FIXME: 警告注释文字 来代替OC中的 #warning 警告注释文字;同时新增了一个 // TODO: 具体对比如下截图:

下面是OC中的注释

网友评论