Get a view controller's class name as string

xonegirlz picture xonegirlz · Jun 5, 2012 · Viewed 21.9k times · Source

If I have a UIViewController subclass, how can I get the class name as string? I've tried doing [vc class], but this returns a Class object, not an NSString.

Answer

jscs picture jscs · Jun 5, 2012

NSStringFromClass

Returns the name of a class as a string.

NSString * NSStringFromClass (  
    Class aClass  
);