//
//  NSObject+EasySubClass.m
//  Gengmei
//
//  Created by wangyang on 2019/9/5.
//  Copyright © 2019 更美互动信息科技有限公司. All rights reserved.
//

#import "NSObject+EasySubClass.h"
#import <objc/runtime.h>

@implementation NSObject (EasySubClass)
+ (instancetype)initWithSubclassName:(NSString *)clsName {
    const char *subclassName = clsName.UTF8String;
    Class subclass = objc_getClass(subclassName);
    if (subclass == nil) {
        subclass = objc_allocateClassPair(self, subclassName, 0);
        if (subclass == nil) {
            return [self new];
        }
        objc_registerClassPair(subclass);
    }
    return [subclass new];
}

@end
