代码片段快捷键 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 就是我们的开发利器. 上一篇文章,介绍了一个很棒的快捷键,如果你还没用过这个快捷键,看完之后应该会豁然开朗.如果你已经熟练的应用它,也会温故而知新 ...
随机推荐
- 16/7/7_PHP-面向对象关键词
转载地址: http://blog.sina.com.cn/s/blog_5182b171010092fb.html PHP5 是一具备了大部分面向对象语言的特性的语言,比PHP4 有了很多的面向对象 ...
- Jmeter的中英文互换
1.jmeter的中英文互换:为了更深入的了解Jmeter,一般使用英文版的jmeter. 旧版本下载的默认中文较多.新版本5.1的下载后默认英文比较的多. 方法一: 选项->选择一种语言,但是 ...
- 【ABAP系列】SAP ABAP实现发送外部邮件(添加附件)功能
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP ABAP实现发送外部邮件(添 ...
- codeforces#1215E. Marbles(状压DP)
题目大意:给出一个由N个整数组成的序列,通过每次交换相邻的两个数,使这个序列的每个相同的数都相邻.求最小的交换次数. 比如给出序列:1 2 3 2 1 ,那么最终序列应该是 1 1 2 2 3 ,最小 ...
- 个人对BFC的见解
BFC:块级格式化上下文,它是指一个独立的块级渲染区域,只有Block-level BOX参与,该区域拥有一套渲染规则来约束块级盒子的布局,且与区域外部无关. BFC的生成 既然上文提到BFC是一块渲 ...
- 分享一篇Linux系统使用Tomcat服务时交互式修改server.xml中端口号的shell脚本
#!/bin/bash echo -e '\n' echo "***********************************" port1=`grep -r "s ...
- [常用类]时间内Date、SimpleDateFormat、Calendar类
Date类的概述是util包下的,不能导入sql包的.* 类 Date 表示特定的瞬间,精确到毫秒. *构造方法 * public Date() * public Date(long date) 如果 ...
- FZUOJ-2273 Triangles
Problem 2273 Triangles Accept: 109 Submit: 360 Time Limit: 1000 mSec Memory Limit : 262144 KB ...
- hadoop编程小技巧(1)---map端聚合
測试hadoop版本号:2.4 Map端聚合的应用场景:当我们仅仅关心全部数据中的部分数据时,而且数据能够放入内存中. 使用的优点:能够大大减小网络数据的传输量,提高效率: 一般编程思路:在Mapp ...
- Windows下的vue-devtools工具的安装
详细教程在这个链接里: https://www.cnblogs.com/xqmyhome/p/10972772.html