代码片段快捷键 CodeSnippets
CodeSnippets
https://github.com/jaydee3/CodeSnippets
These are my Xcode 4 CodeSnippets.
To use them, clone this repository into the following path:
cd ~/Library/Developer/Xcode/UserData/CodeSnippets
git clone git@github.com:jaydee3/CodeSnippets.git .
(The folder must be empty, to clone the repository directly in it.)
And you're ready to go.
Installing
the pre-commit hook
This README is generated automatically using .generateDescription.py.
To run this script automatically before each commit, install the pre-commit hook like this:
sh .install-precommit-hook.sh
Snippet
Descriptions
addAChildViewcontroller.codesnippet (Add a child ViewController)
Shortcut: childController
Adds a child ViewController to self
UIViewController *newController = <#newController#>;
[newController willMoveToParentViewController:self];
[self addChildViewController:newController];
[self.contentView addSubview:newController.view];
[newController didMoveToParentViewController:self];
blockSafeSelfPointer.codesnippet (Block safe self pointer)
Shortcut: bs
A weak pointer to self (for usage in blocks).
__weak typeof(self) blockSelf = self;
createAndShowAUialertview.codesnippet (Create & show a UIAlertView)
Shortcut: alertview
Shows a newly created alertview
[[[UIAlertView alloc] initWithTitle:<#title#>
message:<#message#>
delegate:<#self#>
cancelButtonTitle:<#nil#>
otherButtonTitles:<#nil#>] show];
createAnImageview.codesnippet (Create an imageView)
Shortcut: iv
Inits a new imageView with an image via imageNamed.
[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"<#imageName#>"]]
createAReusableTablecell.codesnippet (Create a reusable TableCell)
Shortcut: tablecell
Initialises / deques a new cell from the tableview using an identifier
// create / dequeue cell
static NSString* identifier = @"<#identifier#>";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[<#UITableViewCell#> alloc] initWithStyle:<#UITableViewCellStyleSubtitle#> reuseIdentifier:identifier];
}
return cell;
decrementingForLoop.codesnippet (Decrementing For Loop)
Shortcut: fori
A For Loop decrementing a local variable
for (NSInteger i=<#startValue#>; i><#count#>; i--) {
<#statements#>
}
formattedString.codesnippet (Formatted String)
Shortcut: format
Shortcut for a formatted string
[NSString stringWithFormat: @"<#string#>", <#param1#>]
getDocumentsDirectory.codesnippet (Get Documents directory)
Shortcut: documents
Create path to documents directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"<#fileName#>"];
importFramework.codesnippet (Import Framework)
Shortcut: imp2
import a framework
#import <<#header#>>
importHeader.codesnippet (Import header)
Shortcut: imp1
Import a header
#import "<#header#>"
incrementingForLoop.codesnippet (Incrementing For Loop)
Shortcut: fori
A For loop incrementing a local variable
for (NSInteger i=0; i<<#count#>; i++) {
<#statements#>
}
initalizeAnObject.codesnippet (Initalize an object)
Shortcut: alloc
creates a new object from a given class
<#ClassName#> *<#variableName#> = [[<#ClassName#> alloc] init];
keyValuePairForLocalization.codesnippet (Key-Value Pair for Localization)
Shortcut: key
A localization key and its value
"<#keyName#>" = "<#value#>";
localizeAString.codesnippet (Localize a string)
Shortcut: loca
Localizes a string from a given key
NSLocalizedString(@"<#keyName#>", nil)
pragmaMark.codesnippet (Pragma mark)
Shortcut: pragma
Add a new pragma mark
#pragma mark <#comment#>
pushAViewcontroller.codesnippet (Push a ViewController)
Shortcut: push
Pushes a newly created ViewController on the current NavigationController
<#UIViewController#>* viewController = [[<#UIViewController#> alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
setupAutoresizingOfAView.codesnippet (Setup autoresizing of a view)
Shortcut: autoresizing
Set the autoresizing flags of a view
<#view#>.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
singleton.codesnippet (singleton)
Shortcut: singleton
A singleton implementation using dispatch_once
+ (instancetype)<#sharedInstance#> {
static id <#_sharedInstance#> = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
<#_sharedInstance#> = [[self alloc] init];
});
return <#_sharedInstance#>;
}
代码片段快捷键 CodeSnippets的更多相关文章
- VS Code 折腾记 - (6) 基本配置/快捷键定义/代码片段的录入(snippet)
前言 本来分成三篇来写的,但是想了想没必要,大家都是聪明人...简单的东西点一下就晓得了. 基本配置 快捷键自定义(Ctrl+K Ctrl + S) 那个when支持条件表达式返回一个布尔值 支持的快 ...
- 使用 Git 来管理 Xcode 中的代码片段
使用 Git 来管理 Xcode 中的代码片段 代码片段介绍 xcode4 引入了一个新 feature: code snippets,在整个界面的右下角,可以通过快捷键:cmd + ctrl + o ...
- iOS开发技巧 -- 复用代码片段
如果你是一位开发人员在开发过程中会发现有些代码无论是在同一个工程中还是在不同工程中使用率会很高,有经验的人会直接封装在一个类里,或者写成一个宏定义或者把这些代码收集起来,下次直接使用,或者放到xcod ...
- 创建自己的代码片段(CodeSnippet)
前言 工作中经常会写一些重复的代码片段,如自动属性.for循环.Action等等,针对这种情况,VisualStudio已经给我们提供了一个非常方便的功能--代码片段,是我们可以简单的输入几个字母就能 ...
- 使用Github来管理的代码片段
代码片段介绍 xcode4引入了一个新feature: code snippets,在整个界面的右下角,可以通过快捷键:cmd + ctrl + opt + 2 调出来.code snippets是一 ...
- Visual Studio 代码片段
管理界面 打开 工具 >> 代码片段管理器 界面 使用步骤 选择对应语言. 选择一个片段的文件夹. 打开该文件夹的位置. 复制任意一个片段. 对复制出来的片段进行修改.(具体修改内容见例子 ...
- iOS开发-代码片段(Code Snippets)提高开发效率
简介 在 XCode4 引入了一个新特性,那就是“代码片段(Code Snippets)”.对于一些经常用到的代码,抽象成模板放到 Code Snippets 中,使用的时候就只需要键入快捷键就可以了 ...
- c#代码片段新建(sinppet)
在c#里面我们经常用到 1.if 然后按2下Tab,出来下面一段代码 if (true) { } 2.propfull private int myVar; public int MyProperty ...
- VS里的 代码片段(Code snippet)很有用,制作也很简单
工欲善其事必先利其器,而 Visual Studio 就是我们的开发利器. 上一篇文章,介绍了一个很棒的快捷键,如果你还没用过这个快捷键,看完之后应该会豁然开朗.如果你已经熟练的应用它,也会温故而知新 ...
随机推荐
- loadrunner+win2003虚拟机的安装
lr11的安装和使用 准备材料: 1.win2003镜像下载 2.虚拟机下载 3.lr11的下载 一.创建win2003虚拟机 打开虚拟机,选择win2003系统镜像,输入密钥(可百度),用户名密码( ...
- Bootstrap 学习笔记 项目实战 首页内容介绍 上
效果图: HTML代码: <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset ...
- 2019春第十二周作业Compile Summarize
这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 这里 我在这个课程的目标是 能按自己的想法解出题目 这个作业在那个具体方面帮助我实现目标 能朝着软件工程师方向发展 参考文献与网址 C语言 ...
- Java相关面试题总结+答案(七)
[Hibernate] 113. 为什么要使用 hibernate? hibernate 是对 jdbc 的封装,大大简化了数据访问层的繁琐的重复性代码. hibernate 是一个优秀的 ORM 实 ...
- [集合Set]HashSet、LinkedHashSet TreeSet
Set Set是不包含重复元素的集合.更正式地,集合不包含一对元素e1和e2,使得e1.equals(e2),并且最多一个空元素. 无索引,不可以重复,无序(存取不一致) Set接口除了继承自Coll ...
- display:table的几个用法 块级子元素垂直居中
DIV+CSS的布局已经让表格布局几乎很少用到,除非表格语义性很强的情况. display:table解决了一部分需要使用表格特性但又不需要表格语义的情况, 尤其是DIV+CSS很不方便解决的问题,比 ...
- 一台电脑关联多个git账号
一台电脑连接多个git账号 现需要一台电脑连接gitlab,github,码云,之前的操作时,用公司账号,在这几个地方都注册一遍,导致自己就有两类号,一个自己的,一个公司的,这样也是可以,但总是不太好 ...
- nginx入门(一)
什么是nginx? nginx是一款高性能的http 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器.由俄罗斯的程序设计师Igor Sysoev所开发,官方测试nginx能够支支撑5 ...
- vue项目中使用高德地图(根据坐标定位点)
前言 项目中需要根据坐标定位,将自己的实现过程写下来,废话不多说,上代码 正文 <script> var map,marker; export default { data(){ retu ...
- 案例 element 表单名两端对齐
>>> .el-form-item label:after { content: ""; display: inline-block; width: 100%; ...