码迷,mamicode.com
首页 > 编程语言 > 详细

swift类型操作规范

时间:2018-05-29 19:06:12      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:HERE   inter   ini   reg   call   obj   www   you   ret   

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类型操作规范

标签:HERE   inter   ini   reg   call   obj   www   you   ret   

原文地址:https://www.cnblogs.com/feng9exe/p/9106390.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!