返回当前类的类名

  • ForExample:在当前类中添加如下方法:
+ (UIStoryboard*)fromName:(NSString*)name
{
    return [UIStoryboard storyboardWithName:name bundle:[NSBundle mainBundle]];
}
  • 封装(返回storyboard)
/**
 *  初始化控制器
 */
+ (id)create
{
    NSString *className = NSStringFromClass([self class]);
    id newObj = [[UIStoryboard fromName:className] instantiateInitialViewController];
    return newObj;
}
  • 封装(返回)
/**
 *  根据当前storyboard名字和id名获得当前storyboard
 */
+ (id)createFromStoryboardName:(NSString *)name withIdentifier:(NSString *)identifier;
{
    if (name && identifier) {
        UIStoryboard *storyboard = [UIStoryboard fromName:name];
        return [storyboard instantiateViewControllerWithIdentifier:identifier];
    }
    return nil;
}

你可能感兴趣的:(返回当前类的类名)