
Swift 3中的type(of:x)似乎不适用于is类型检查
它只是给出了此错误消息:
Consecutive statements on a line must be separated by ‘;’
代码示例:
class Test : UIVIEwController {}let test = test()let test2 = test()let isEqual = test2 is type(of: test) // this does not compile 这有什么不对?
如何在Swift 3中进行这样的动态类型检查?
class Test : UIVIEwController {}class Test1 : UIVIEwController {}let test = test()let test2 = Test1()let f = test2.isKind(of: test2.classForCoder)print(f) Output: true
这可能是检查类型的另一个想法
除此之外
let q = type(of: test) == type(of: test)
将返回true,但仅当它是同一个类而不是子类时
总结以上是内存溢出为你收集整理的Swift 3中的type(of :)似乎不适用于类型检查全部内容,希望文章能够帮你解决Swift 3中的type(of :)似乎不适用于类型检查所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)