swift类型操作规范
type(of:)
Applied to an object: the polymorphic (internal) type of the object, regardless of how a reference is typed. Static/class members are accessible by passing an object to type(of:).
.Type
Sent to a type in a type declaration: the polymorphic type. For example, in a function parameter declaration, Dog means a Dog instance is expected (or an instance of one its subclasses), but Dog.Type means that the Dog type itself is expected (or the type of one of its subclasses).
.self
Sent to a type: the type. For example, to pass the Dog type where Dog.Type is expected, you can pass Dog.self.
self
In instance code, this instance, polymorphically. In static/class code, this type, polymorphically; self.init(...) instantiates the type.
Self
In a method declaration, when specifying the return type, this class or this instance’s class, polymorphically.
http://www.apeth.com/swiftBook/ch04.html#_type_reference
swift类型操作规范的更多相关文章
- swift 类型.
swift 类型 变量声明 用let来声明常量,用var来声明变量 可以在一行中声明多个常量或者多个变量,用逗号隔开 var x = 0.0, y = 0.0, z = 0.0 类型安全 Swift ...
- Swift类型检查与转换
继承会发生在子类和父类中,如图所示,是一系列类的继承关系类图,Person是类层次结构中的根类,Student是Person的直接子类,Worker是Person的直接子类.这个继承关系类图的具体实现 ...
- Swift—类型检查与转换-备
继承会发生在子类和父类之间,是一系列类的继承关系. 例如:Person是类层次结构中的根类,Student是Person的直接子类,Worker是Person的直接子类. 这个继承关系类的具体实现代码 ...
- Swift - 类型判断is 与 类型转换as
在Swift中,通常使用is和as操作符来实现类型检查和转换.下面通过样例来演示使用方法,首先定义几个类. 1 2 3 4 5 6 7 8 9 10 11 //基类,人类 class Human{ } ...
- Swift类型推测在可选调用中的小提示
我们知道Swift中协议里也有对应于Objc中的可选方法或计算属性,当然协议必须以@objc伪指令修饰否则不可以哦. 如下示例: @objc protocol Transaction{ fun com ...
- Swift 类型桥接
前言 iOS 中的 API 基本都是在许多年前由 OC 写成的,现在通过桥接的方法在 Swift 中可以用,基本看不出区别,非常自然.但是一些特殊的类型,在两种语言进行桥接的时候需要特别注意. 1.N ...
- Swift 类型嵌套
1.类型嵌套 Swift 支持类型嵌套,把需要嵌套的类型的定义写在被嵌套的类型的 {} 中. Swift 中的枚举类型可以辅助实现特定的类或者结构体的功能. struct SchoolUniform ...
- swift类型擦除的定义-swift的类型擦除只是一个类型高低阶转换的游戏。
所谓swift的类型擦除是指: moand转换: 通过技术手段(通常是包装器),将具体类型的类型信息擦除掉了,只将类型的(某一个侧面的)抽象信息(通常指的是类型尊从的协议.接口.或基类)暴露出来. A ...
- Swift 类型检查与类型转换
前言 在 Swift 语言中一般使用 is 关键字实现类型检查,使用 as 关键字实现类型转换,除此之外还可以通过构造器和方法来实现类型转换. 1.类型检查 1.1 使用 is 检查 类型检查操作符 ...
随机推荐
- php第六讲
继承和静态 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...
- 复习C语言基础知识(day02)
一.大型软件组织 定义规则,规则就是协议.用户和中介的接口. 软件开发的过程: 定义规则,定义协议.软件为用户提供的功能. 在C语言中使用接口实现.接口就是函数. 两种用户 函数的使用者 函数的实现者 ...
- Git 基础教程 之 分支管理及策略
创建一个属于自己的分支,别人看不到,你在你自己的分支上干活, 想提交就提交,直至开发完毕后,再一次性合并到原来分支上.这样,既安全,又不影响他人工作. 在实际的开发过程中,应照几个基 ...
- Git 基础教程 之 创建版本库
一,选择一个合适的地方,创建空目录,下面两种方法都可 ① 手动新建 ② 使用命令: mkdir pythonwork 二,初始化,使目录变成Git可管理的仓库 执行: git i ...
- Vue + Element 小技巧
说是小技巧 ,其实就是本人 就是一个小菜比 .如有大佬可以纠正,或者再救救我这个小菜比 跪谢 1.当后台返回一个字段需要根据不同字段内容在表格内显示相对应的文字(字段内容是死的,表格内需要显示对 ...
- 使用PSI-probe监控tomcat7
http://www.lambdaprobe.org/ http://blog.csdn.net/tanglei6636/article/details/70169153 http://blog.cs ...
- Java基础教程:tutorialspoint-spring mvc
教程: 来自turorialspoint的Spring MVC 4.1.6教程(英文),官网:https://www.tutorialspoint.com/springmvc/index.htm 离线 ...
- Go在Ubuntu 14.04 64位上的安装过程
1. 从 https://golang.org/dl/ 或 https://studygolang.com/dl 下载最新的发布版本go1.10即go1.10.linux-amd64.tar.gz ...
- hadoop1.0.4升级到hadoop2.2 具体流程步骤
hadoop1.x 升级到hadoop2.2 本文參考了博客:http://blog.csdn.net/ajax_jquery/article/details/27311671,对一些地方做了改动. ...
- LeetCode(1) Symmetric Tree
从简单的道题目開始刷题目: Symmetric Tree 题目:Given a binary tree, check whether it is a mirror of itself (ie, sym ...