傳送門HLCodeBlocks舶替,直接拷貝至~/Library/Developer/Xcode/UserData/
即可
1.Xcode自定義代碼塊
方式一:
1.選中代碼塊
2.鼠標(biāo)右鍵凡纳,選擇`Create Code Snippet...`
方式二:
1.選中Xcode導(dǎo)航上的`Editor`
2.選擇`Create Code Snippet...`
2.編輯代碼塊
3.常用代碼塊
weakSelf
__weak typeof(self) weakSelf = self;
strongSelf
__strong typeof(weakSelf) strongSelf = weakSelf;
pstring
@property (nonatomic, copy) NSString *
pstringn
@property (nonatomic, copy) NSString *<#name#>
pstrong
@property (nonatomic, strong)
pcopy
@property (nonatomic, copy)
passign
@property (nonatomic, assign)
pprotocol
@property (nonatomic, weak) id<<#protocol#>> delegate;
tdd
UITableView的dataSource俗冻、delegate
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return <#expression#>;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
<#Class#> *cell = [tableView dequeueReusableCellWithIdentifier:<#(nonnull NSString *)#> forIndexPath:indexPath];
return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return <#expression#>;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
cdd
UICollectionView的dataSource桑逝、delegate、delegateFlowLayout
#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return <#expression#>;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
<#Class#> *cell = [collectionView dequeueReusableCellWithReuseIdentifier:<#(nonnull NSString *)#> forIndexPath:indexPath];
return <#expression#>;
}
#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
}
#pragma mark - UICollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return <#expression#>;
}
after
GCD延時
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
<#code#>
});
shared
單例
+ (instancetype)sharedInstance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[<#Class#> alloc] init];
});
return instance;
}
mark
mark標(biāo)注
#pragma mark - Private Mehtod
#pragma mark - Public Mehtod
#pragma mark - Response Event
main
GCD回到主線程
dispatch_async(dispatch_get_main_queue(), ^{
<#code#>
});
4.以上代碼塊拷貝至一下路徑:
傳送門HLCodeBlocks
~/Library/Developer/Xcode/UserData/