不想改动原有init方法的扩展

因为原有的在很多地方都有调用,不想动,后面又想添加,代码如下:

- (instancetype)initWithFastShopModel:(FastShopModel *)fastShopModel

               {
    self = [super init];
    if (self){
        self.fastShopModel = fastShopModel;
    }
    return self;
}

- (instancetype)initWithMyShopMutableDic:(NSMutableDictionary *)myShopMutableDic{
    
    FastShopModel *fastShopModel = [FastShopModel new];
    fastShopModel.code = [myShopMutableDic validStringValueForKey:@"code"];
    fastShopModel.company = [myShopMutableDic validStringValueForKey:@"company"];
    fastShopModel.dbname = [myShopMutableDic validStringValueForKey:@"dbname"];
    QbuyDetailVC *qbuyDetailVC = [self initWithFastShopModel:fastShopModel];
    return qbuyDetailVC;
}

拿原有的UIViewController返回进行修改,虽然看起来是两个init,其实是一个init

你可能感兴趣的:(不想改动原有init方法的扩展)