iOS Xcode自定义代码块及迁移的实现方法

前端之家收集整理的这篇文章主要介绍了iOS Xcode自定义代码块及迁移的实现方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

前言

文中将要介绍以下四点内容

下面话不多说了,来一起看看详细的介绍吧

一 . 意义在于节约时间成本

  1. like
  2. 我在编译器键入 strong,回车
  3. 自动生成
  4. @property (nonatomic,strong) <#Class#> *<#object#>;

二 . 如何自定义代码

如下图所示 选中一行代码右键 crate code snippet

右上角方框快速进入

iOS Xcode自定义代码块及迁移的实现方法

图1

下图填入描述,以及快捷方式

iOS Xcode自定义代码块及迁移的实现方法

图2

三 . iOS Xcode自定义代码块迁移

  1. Command + Shift + G. 前往如下路径的文件
  2. 路径 : ~/Library/Developer/Xcode/UserData/CodeSnippets
  3. 文件夹内部的文件复制,粘贴到另一台电脑的Xcode同样的文件夹中即可
  4. 重启xcode

四 . 代码块编写

下面我举个栗子 . 0.O

  1. - (UITableView *)<#tableview#> {
  2.  
  3. if(!<#tableview#>) {
  4.  
  5. <#tableview#> = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
  6. <#tableview#>.delegate =self;
  7. <#tableview#>.dataSource =self;
  8. [<#tableview#> registerClass:[<#cell#> class] forCellReuseIdentifier:@"cellIdentifier"];
  9. }
  10. return <#tableview#>;
  11. }
  12.  
  13. #pragma mark - tableView delegate
  14. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  15.  
  16. return <#expression#>
  17. }
  18.  
  19. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  20.  
  21. return <#expression#>
  22. }
  23.  
  24. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  25.  
  26. <#UITableViewCell#> *cell = [tableView dequeueReusableCellWithIdentifier:@"cellIdentifier"];
  27. return cell;
  28.  
  29. }
  30.  
  31. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  32.  
  33. }

注: <#class#> 即为可以替换的词语.

我再举个栗子

  1. @property (nonatomic,assign) <#Class#> <#object#>;

总结

留作备忘

给需要的人

好了,以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对我们的支持

猜你在找的iOS相关文章