[swift-dev] Swift root meta-class

John McCall rjmccall at apple.com
Mon May 8 17:30:59 CDT 2017

> On May 8, 2017, at 6:21 PM, Giacomo Leopizzi via swift-dev <swift-dev at swift.org> wrote:
> Hello everyone! 
> I was discussing with a friend about metaclasses in Objective-C. In Obj-C the root meta-class was the NSObject's one.

ObjC does not have a single root class.  Most ObjC classes inherit from NSObject, but that is not guaranteed, and in fact there are other common root classes including NSProxy.

> When in a swift class you create a subclass of NSObject, the root metaclass should be the same. What happen when you delcare a class without NSObject dependence? There is an hidden root-class? Where can we read more about this topic? 

When ObjC interop is enabled, Swift classes that do not inherit from NSObject use a private root class.  However, that is a private implementation detail and we don't promise much about it.

Do you have any specific questions?


More information about the swift-dev mailing list