V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
eato
V2EX  ›  C

How to print out the name of an object in Objective-C?

  •  
  •   eato · 2014 年 7 月 27 日 · 1355 次点击
    这是一个创建于 4200 天前的主题,其中的信息可能已经有所发展或是发生改变。
    第 1 条附言  ·  2014 年 7 月 27 日
    anArray contain several objects,

    for (theObject *p in anArray) {
    NSLog(@"object's name:%@, others...", p.description, ...);
    }

    How to override description to return the object's name?
    第 2 条附言  ·  2014 年 7 月 27 日
    @Zhang 是这个意思,谢谢!
    6 条回复    2014-07-27 21:16:38 +08:00
    dorentus
        1
    dorentus  
       2014 年 7 月 27 日   ❤️ 1
    Define “the name of an object”。
    ETiV
        2
    ETiV  
       2014 年 7 月 27 日 via iPhone   ❤️ 1
    [[obj class] description]?
    Zhang
        3
    Zhang  
       2014 年 7 月 27 日   ❤️ 1
    @dorentus He probably means the name of the pointer which points to the object.
    sumanx
        4
    sumanx  
       2014 年 7 月 27 日
    NSStringFromClass([obj class])
    nikolai
        5
    nikolai  
       2014 年 7 月 27 日
    NSString * NSStringFromClass(Class aClass);
    canautumn
        6
    canautumn  
       2014 年 7 月 27 日
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2298 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:54 · PVG 23:54 · LAX 07:54 · JFK 10:54
    ♥ Do have faith in what you're doing.