类名与字符串的互转
类名转类
id class = NSClassFromString([NSString stringWithFormat:@"%@Controller", self.viewName]);
类转类名
NSString *className = NSStringFromClass([UIView class]);
其他转换
FOUNDATION_EXPORT NSString *NSStringFromSelector(SEL aSelector); //SEL转字符串 FOUNDATION_EXPORT SEL NSSelectorFromString(NSString *aSelectorName); //字符串转SEL FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) NS_AVAILABLE(10_5, 2_0); //协议转字符串 FOUNDATION_EXPORT Protocol * __nullable NSProtocolFromString(NSString *namestr) NS_AVAILABLE(10_5, 2_0); //字符串转协议
http://www.cnblogs.com/PaulpauL/
版权声明:本文为博主原创文章,未经博主允许不得转载。