Skip to content

Instantly share code, notes, and snippets.

@troystribling
Created May 5, 2012 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troystribling/2603108 to your computer and use it in GitHub Desktop.
Save troystribling/2603108 to your computer and use it in GitHub Desktop.
Objective C Class Name as String
#import <objc/runtime.h>
@interface NSObject (Extensions)
- (NSString*)className;
@end
@implementation NSObject (Extensions)
- (NSString*)className {
return [NSString stringWithUTF8String:(char*)class_getName([self class])];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment