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

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

  •  
  •   eato · 2014-07-27 14:14:17 +08:00 · 902 次点击
    这是一个创建于 3561 天前的主题,其中的信息可能已经有所发展或是发生改变。
    第 1 条附言  ·  2014-07-27 16:51:20 +08:00
    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-07-27 23:43:35 +08:00
    @Zhang 是这个意思,谢谢!
    6 条回复    2014-07-27 21:16:38 +08:00
    dorentus
        1
    dorentus  
       2014-07-27 14:28:08 +08:00   ❤️ 1
    Define “the name of an object”。
    ETiV
        2
    ETiV  
       2014-07-27 14:44:25 +08:00 via iPhone   ❤️ 1
    [[obj class] description]?
    Zhang
        3
    Zhang  
       2014-07-27 15:53:25 +08:00   ❤️ 1
    @dorentus He probably means the name of the pointer which points to the object.
    sumanx
        4
    sumanx  
       2014-07-27 17:03:06 +08:00
    NSStringFromClass([obj class])
    nikolai
        5
    nikolai  
       2014-07-27 18:18:38 +08:00
    NSString * NSStringFromClass(Class aClass);
    canautumn
        6
    canautumn  
       2014-07-27 21:16:38 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   888 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 21:42 · PVG 05:42 · LAX 14:42 · JFK 17:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.