代码片段快捷键 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 就是我们的开发利器. 上一篇文章,介绍了一个很棒的快捷键,如果你还没用过这个快捷键,看完之后应该会豁然开朗.如果你已经熟练的应用它,也会温故而知新 ...
随机推荐
- 2019寒假作业一:PTA7-1 打印沙漏
- 打印沙漏 ( 分) 本题要求你写个程序把给定的符号打印成沙漏的形状.例如给定17个“*”,要求按下列格式打印 ***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇数个符号: ...
- 简历内容-resume
1.TCP.UDP通信 服务器客户端 网络层 2.http协议 通信 网络编程 应用层 根据公司给出的应用层协议开发指定程序: 3.json cjson Cjson解析器 4.freeRT ...
- PPT制作,数据图等画图
1. mathcad 画图简单不错 2.三维图 matlab不错 3.PPT 学术ppt,美观明了,思路清晰,数据可视化 学术PPT: http://mp.weixin.qq.com/s/TPYW ...
- 从ES6重新认识JavaScript设计模式: 装饰器模式
1 什么是装饰器模式 向一个现有的对象添加新的功能,同时又不改变其结构的设计模式被称为装饰器模式(Decorator Pattern),它是作为现有的类的一个包装(Wrapper). 可以将装饰器理解 ...
- MS COCO 数据集学习笔记(Common Objects in COntext)
一.数据来源 COCO中图片资源均引用自Flickr图片网站 二.数据集创建目的 进行图像识别训练,主要针对以下三个方向: (1)object instances (2)object keypoint ...
- HTML5-video(播放暂停视频;打开关闭声音;进度条)
<!DOCTYPE html> <html> <head> <title>HTML5-video(播放暂停视频:打开关闭声音:进度条)</titl ...
- jenkins使用记录转自https://my.oschina.net/sanpeterguo/blog/197931
摘要: jenkins(持续集成开源工具)提供了丰富的api接口,基本上所有的操作都可以使用curl来从后台调度,包括:创建项目,禁用项目,启用项目,获取项目描述,获取配置文件,普通触发,scm触发, ...
- 什么是dockerfile?
什么是dockerfile? Dockerfile是一个包含用于组合映像的命令的文本文档.可以使用在命令行中调用任何命令. Docker通过读取Dockerfile中的指令自动生成映像. docker ...
- Linux终端复用工具tmux的使用和配置
1. 会话管理 新建会话 $ tmux new -s session-one -d -s:指定回话名称 -d:会话在后台运行 查看所有会话 $ tmux ls session-one: 1 windo ...
- C# ASP.NET发送电子邮件System.Net.Mail
1.补充知识 (1)POP3和SMTP服务器是什么? 简单点来说:POP3 用于接收电子邮件 ,SMTP 用于发送电子邮件. (1)POP3具体指什么? POP3(Post Office Protoc ...