[swift-dev] Swift root meta-class

Giacomo Leopizzi gi.le at icloud.com
Mon May 8 17:46:29 CDT 2017


Our starting point was that in ObjC at the beginning of the execution, the root meta-class (most of the time NSObject) instantiates all the other meta-classes, that create the class as object for the software. In Swift is it the same? If so, which is the name of the root meta-class? 
Thanks for the fast reply. 

Giacomo 

> On 9 May 2017, at 00:30, John McCall <rjmccall at apple.com> wrote:
> 
>> 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?

> 
> John.



More information about the swift-dev mailing list