V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
eato
V2EX  ›  C

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

  •  
  •   eato · Jul 27, 2014 · 1480 views
    This topic created in 4305 days ago, the information mentioned may be changed or developed.
    Supplement 1  ·  Jul 27, 2014
    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?
    Supplement 2  ·  Jul 27, 2014
    @Zhang 是这个意思,谢谢!
    6 replies    2014-07-27 21:16:38 +08:00
    dorentus
        1
    dorentus  
       Jul 27, 2014   ❤️ 1
    Define “the name of an object”。
    ETiV
        2
    ETiV  
       Jul 27, 2014 via iPhone   ❤️ 1
    [[obj class] description]?
    Zhang
        3
    Zhang  
       Jul 27, 2014   ❤️ 1
    @dorentus He probably means the name of the pointer which points to the object.
    sumanx
        4
    sumanx  
       Jul 27, 2014
    NSStringFromClass([obj class])
    nikolai
        5
    nikolai  
       Jul 27, 2014
    NSString * NSStringFromClass(Class aClass);
    canautumn
        6
    canautumn  
       Jul 27, 2014
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3018 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 08:28 · PVG 16:28 · LAX 01:28 · JFK 04:28
    ♥ Do have faith in what you're doing.