美文网首页
iOS Xcode自定义代码块及常用代码块

iOS Xcode自定义代码块及常用代码块

作者: 落寞绅士 | 来源:发表于2022-06-22 11:04 被阅读0次

传送门HLCodeBlocks,直接拷贝至~/Library/Developer/Xcode/UserData/即可

1.Xcode自定义代码块

方式一:
1.选中代码块 
2.鼠标右键,选择`Create Code Snippet...`
图片.png
方式二:
1.选中Xcode导航上的`Editor`
2.选择`Create Code Snippet...`
图片.png

2.编辑代码块

图片.png

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

afterGCD延时

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标注

#pragma mark - Private Mehtod

#pragma mark - Public Mehtod

#pragma mark - Response Event

mainGCD回到主线程

dispatch_async(dispatch_get_main_queue(), ^{
        <#code#>
    });

4.以上代码块拷贝至一下路径:

传送门HLCodeBlocks

~/Library/Developer/Xcode/UserData/

相关文章

  • iOS Xcode自定义代码块以及迁移

    iOS Xcode自定义代码块以及迁移 iOS Xcode自定义代码块以及迁移

  • iOS Xcode自定义代码块及常用代码块

    传送门HLCodeBlocks[https://github.com/huangchangweng/HLCodeB...

  • #Xcode自定义代码块

    Xcode自定义代码块 如下图,为Xcode保存的代码块(包括自定义的,自定义的有个User的下标) 选中代码块 ...

  • 2019-05-31

    iOS 自定义代码块的方法新版xcode 我们Xcode的代码块更新之后就到了这里.如果 点开之后找了许久也没看到...

  • Xcode 代码块

    创建 Xcode 代码块快捷键可以提高代码输入速度。常用代码块如下: 将上面所需的代码块选中后,拖到 Xcode ...

  • Xcode自定义代码块 快捷输入

    1、认识 Xcode 代码块 2、创建 Xcode 代码块 当然,代码块功能之所以强大,是因为你可以创建自定义的代...

  • 武装你的Xcode(三)- 代码块Snippets

    1、认识 Xcode 代码块 2、创建 Xcode 代码块 当然,代码块功能之所以强大,是因为你可以创建自定义的代...

  • iOS Code Snippet Library 自定义代码段

    CodeSnippet Xcode自定义代码块,让开发更加效率 你可以在Xcode中自定义自己的代码块,设置自己习...

  • xcode 常用代码块

    在Xcode10正式发布之后,喜欢使用代码块的小伙伴会发现,原先位于编辑器右下角的代码块标识被放到上面了,点击 {...

  • Xcode常用代码块

    代码块路径 (注意:如果你的xcode没有添加过代码块,那你是找不到这个文件夹的) ~/Library/Devel...

网友评论

      本文标题:iOS Xcode自定义代码块及常用代码块

      本文链接:https://www.haomeiwen.com/subject/jonyvrtx.html