Xcode 常用代码段

时间:2023-03-09 16:30:16
Xcode 常用代码段
  • weak_shortcut
/** <#注释#> */
@property(nonatomic,weak) <#class#> *<#name#>;
  • copy_shortcut
/** <#注释#> */
@property(nonatomic,copy) NSString *<#name#>;
  • bool_shortcut
/** <#注释#> */
@property(nonatomic,assign) BOOL <#name#>;
  • block_shortcut
/** <#注释#> */
@property(nonatomic,copy) <#MyBlock#> <#blockName#>;
  • assign_shortcut
/** <#注释#> */
@property(nonatomic,assign) <#class#> <#name#>;
  • lazy_shotcut
- (<#class#> *)<#name#> {
if (_<#name#> == nil) {
_<#name#> = [[<#class#> alloc] init];
}
return _<#name#>;
}
  • setupTableView_snapshot
- (void)setupTableView {

    self.myTableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 10)];
self.myTableView.tableFooterView = [UIView new];
self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.myTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(<#method#>)];
[self.myTableView.mj_header beginRefreshing]; self.myTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(<#method#>)];
self.myTableView.mj_footer.hidden = YES;
}
  • tableviewDelegate&Datasource_snapshot
#pragma mark - UITableViewDelegate, UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return <#number#>;
} - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return <#number#>;
} - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return <#number#>;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return <#number#>;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger row = indexPath.row;
NSInteger section = indexPath.section;
return <#number#>;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger section = indexPath.section;
NSInteger row = indexPath.row;
UITableViewCell *cell; return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DLog(@"");
}
  • mark_shortcut
#pragma mark - <#mark#>