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;
}