Is Float, Double, Int an AnyObject?

前端 未结 3 1797
执念已碎
执念已碎 2021-01-07 19:49

I read inline documentation of Swift and I am bit confused.

1) Any is a protocol that all types implicitly conform.

2) AnyObject

3条回答
  •  醉梦人生
    2021-01-07 20:30

    Good find! UIKit actually converts them to NSNumber - also mentioned by @vacawama. The reason for this is, sometimes you're working with code that returns or uses AnyObject, this object could then be cast (as!) as an Int or other "structs".

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题