How do I get the Objective-C class of an ivar?

前端 未结 3 1845
你的背包
你的背包 2020-12-21 01:04

I have a bunch of simple NSManagedObjects I create in a unit test. They just have a single name attribute of type NSString *. I always

3条回答
  •  一向
    一向 (楼主)
    2020-12-21 01:43

    Maybe i misunderstand what you are trying to achieve. To get the class of an iVar, can't you use the class method of the iVar?

    like:

    NSString *aString = @"random string";
    NSLog(@"%@",NSStringFromClass([aString class]));
    

提交回复
热议问题