代码片段快捷键 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 就是我们的开发利器. 上一篇文章,介绍了一个很棒的快捷键,如果你还没用过这个快捷键,看完之后应该会豁然开朗.如果你已经熟练的应用它,也会温故而知新 ...
随机推荐
- 06 使用bbed修复update的数据--01
场景1 表t3 SQL> select * from t3; ID NAME ---------- -------------------- aaa bbbb SQL> update t3 ...
- 应用安全 - SuiteCRM - 漏洞汇总
CVE-2019-12598.CVE-2019-12601 SuiteCRM SQL注入与远程代码执行漏洞 SalesAgility SuiteCRM .x版本..x版本和7..5之前的7..x版本中 ...
- 将java项目转换成javaWeb项目
1.Ctrl+Shift+R快捷键:找到此项目中的.project文件,打开修改文件内容 在<natures> </natures>代码标签中,添加些内容: <natur ...
- Notepad++-第一篇命令行语句执行之编译、运行Java
1.让Notepad++编译和运行Java,在电脑上要已经配置好了Java的开发环境 2.在Notepad++上面的选项栏中找到 Plugins--->Plugin Admin 3.在Avail ...
- 针对【H-2017年信息基础班(周一班)】某些同学恶意使用lyl洛谷的谴责
我在此发表针对 2019-04-01 17:38 某些hsy班同学恶意使用lyl账号的强烈谴责,望自重!! 以下为证据: 传送门
- 第021讲:函数:lambda表达式
0. 请使用lambda表达式将下边函数转变为匿名函数? def fun_A(x, y=): return x * y me:lambda x,y=3:x*y 1.请将下边的匿名函数转变为普通的屌丝函 ...
- select,poll 和 epoll ??
其实所有的 I/O 都是轮询的方法,只不过实现的层面不同罢了. 其中 tornado 使用的就是 epoll 的. selec,poll 和 epoll 区别总结 基本上 select 有 3 个缺点 ...
- django学习笔记(二)
上节内容回顾: 1.Django请求生命周期 -> URL对应关系(匹配) -> 视图函数 -> 返回用户字符串 -> URL对应关系(匹配) -> 视图函数 -> ...
- JavaScript基础3——使用Button提交表单
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 在Eclipse-jee-neon中配置Hibernate(jbosstools)
以下是在eclipse上安装Hibernate的插件,hibernate在编程上坚持出现,故需要在eclipse上进行如下安装. 首先把安装Hibernate插件,常用到JBoss,访问http:// ...