OC 创建枚举和 数组循环使用

发布时间 2023-05-24 18:35:41作者: 懂事长qingzZ

 

//cell编辑类型
typedef enum :NSInteger{
    ///点击
    MonthRentCellEditTypeClick = 0,
    ///输入
    MonthRentCellEditTypeInput,
    ///删除
    MonthRentCellEditTypeDelete
} MonthRentCellEditType;


@interface ADMonthRentListCellModel: NSObject
///左边标题
@property (copy, nonatomic) NSString *leftTitle;
///右边标题
@property (copy, nonatomic) NSString *rightTitle;
///cell类型 ,点击/输入
@property (assign, nonatomic) MonthRentCellEditType cellEditType;

 

///业务信息
+ (NSArray <ADMonthRentListCellModel *>*)serviceInfoLeftArr{

    NSArray *leftTitleArr = @[@"业务来源",
                              @"业务员/渠道商",
                              @"联系电话",
                              @"是否生成应收账单"
    ];
    
  ///不能直接使用枚举,转成NSNumber 使用才行 NSArray
<NSNumber *>*cellTypeArr = @[@(MonthRentCellEditTypeClick), @(MonthRentCellEditTypeInput)]; return [self getModelArrWithLeftArr:leftTitleArr rightTypeArr:cellTypeArr]; } ///封装 + (NSArray <ADMonthRentListCellModel *>*)getModelArrWithLeftArr:(NSArray<NSString *>*)leftTitleArr rightTypeArr:(NSArray <NSNumber *>*)editorTypeArr{ NSMutableArray <ADMonthRentListCellModel *>* modelArr = [NSMutableArray array]; for (int i = 0; i<leftTitleArr.count; i++) { ADMonthRentListCellModel *cellModel = [[ADMonthRentListCellModel alloc] initWithLeftTitle:leftTitleArr[i] andRightTitle:@"" cellEditType:editorTypeArr[i].integerValue ]; } return modelArr; }