Why does NSDictionary report an unusual class name?

后端 未结 5 1044
孤独总比滥情好
孤独总比滥情好 2021-02-10 09:59
NSDictionary *dict = [NSDictionary dictionary];
NSLog(@\"%@\", NSStringFromClass([dict class])); 

This code prints \"__NSDictionary0\".

For my

5条回答
  •  情话喂你
    2021-02-10 10:25

    NSDictionary is a class cluster. Read about them here:

    Cocoa Fundamentals Guide

    As the "actual" class itself is private, no, it is not safe to depend on this.

    If you need to know if your class is really an NSDictionary or not, use [dict isKindOfClass:[NSDictionary class]];

提交回复
热议问题