Xcode代码块自定义使用

1.代码块使用的变量的地方使用<#type#>

@property (nonatomic,copy) NSString * <#varname#>;

2.拽到代码块栏里设置名称和快捷键



本人收集了一些常用的代码块 ,后续补充中

//1.cell创建
static NSString * identifier = @"<#cellname#>";
+(instancetype)cellWithTableView:(UITableView *)tableView{
    <#cellname#> * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        NSArray *arrayXibObjects = [[NSBundle mainBundle] loadNibNamed:identifier owner:nil options:nil];
        cell =  arrayXibObjects[0];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    tableView.separatorStyle =  UITableViewCellSeparatorStyleNone;
    cell.backgroundColor = [UIColor clearColor];
    cell.userInteractionEnabled = YES;
    cell.accessoryType = UITableViewCellAccessoryNone;
    return cell;
}

//2.单例创建
 static <#classname#> * _instance = nil;
 +(instancetype) shareInstance
 {
 static dispatch_once_t onceToken ;
 dispatch_once(&onceToken, ^{
 _instance = [[self alloc] init] ;
 }) ;
 
 return _instance ;
 }
 
 
 3.tableviewDelegate
#pragma mark  UITableViewDelegate
- (NSInteger)numberOfRowsInSection:(NSInteger)section{
    return <#number#>;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return <#number#>;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    <#classname#> *cell = [AddrListCell cellWithTableView:tableView];
    cell.model = model;
    return cell;
}

#pragma mark 懒加载
-(UITableView *)customTableView
{
    if (!_customTableView) {
        CGRect frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        _customTableView = [[UITableView alloc]initWithFrame:frame];
        _customTableView.backgroundColor = [UIColor whiteColor];
        _customTableView.delegate = self;
        _customTableView.dataSource = self;
        _customTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _customTableView.showsVerticalScrollIndicator = NO;
    }
    return _customTableView;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值