Is Float, Double, Int an AnyObject?

前端 未结 3 1795
执念已碎
执念已碎 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".

提交回复
热议问题