NSString与Class之间的相互转换

Class NSClassFromString (NSString *aClassName);
NSString * NSStringFromClass (Class aClass);

NSString * NSStringFromProtocol (Protocol *proto);
Protocol *NSProtocolFromString (NSString *namestr);

NSString *NSStringFromSelector (SEL aSelector);
SEL NSSelectorFromString (NSString *aSelectorName);
// 还有一种转为char型的字符串接口:

const char* className = class_getName([yourObject class]); 

 

 

posted @ 2014-08-13 01:01  翔子的麦田  阅读(905)  评论(0编辑  收藏  举报