Add an extension/method to all objects in Swift

后端 未结 1 1858
耶瑟儿~
耶瑟儿~ 2021-01-02 09:13

In Objective-C, all objects can be treated as type id, and nearly all objects inherit from NSObject. (Blocks don\'t, but that\'s about the only exception.)

Thus it\'

相关标签:
1条回答
  • 2021-01-02 09:57

    No. You've pretty much answered your own question--Swift objects don't have a base class, and the only real way to get around it is to inherit from NSObject.

    0 讨论(0)
提交回复
热议问题