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的更多相关文章

  1. VS Code 折腾记 - (6) 基本配置/快捷键定义/代码片段的录入(snippet)

    前言 本来分成三篇来写的,但是想了想没必要,大家都是聪明人...简单的东西点一下就晓得了. 基本配置 快捷键自定义(Ctrl+K Ctrl + S) 那个when支持条件表达式返回一个布尔值 支持的快 ...

  2. 使用 Git 来管理 Xcode 中的代码片段

    使用 Git 来管理 Xcode 中的代码片段 代码片段介绍 xcode4 引入了一个新 feature: code snippets,在整个界面的右下角,可以通过快捷键:cmd + ctrl + o ...

  3. iOS开发技巧 -- 复用代码片段

    如果你是一位开发人员在开发过程中会发现有些代码无论是在同一个工程中还是在不同工程中使用率会很高,有经验的人会直接封装在一个类里,或者写成一个宏定义或者把这些代码收集起来,下次直接使用,或者放到xcod ...

  4. 创建自己的代码片段(CodeSnippet)

    前言 工作中经常会写一些重复的代码片段,如自动属性.for循环.Action等等,针对这种情况,VisualStudio已经给我们提供了一个非常方便的功能--代码片段,是我们可以简单的输入几个字母就能 ...

  5. 使用Github来管理的代码片段

    代码片段介绍 xcode4引入了一个新feature: code snippets,在整个界面的右下角,可以通过快捷键:cmd + ctrl + opt + 2 调出来.code snippets是一 ...

  6. Visual Studio 代码片段

    管理界面 打开 工具 >> 代码片段管理器 界面 使用步骤 选择对应语言. 选择一个片段的文件夹. 打开该文件夹的位置. 复制任意一个片段. 对复制出来的片段进行修改.(具体修改内容见例子 ...

  7. iOS开发-代码片段(Code Snippets)提高开发效率

    简介 在 XCode4 引入了一个新特性,那就是“代码片段(Code Snippets)”.对于一些经常用到的代码,抽象成模板放到 Code Snippets 中,使用的时候就只需要键入快捷键就可以了 ...

  8. c#代码片段新建(sinppet)

    在c#里面我们经常用到 1.if 然后按2下Tab,出来下面一段代码 if (true) { } 2.propfull private int myVar; public int MyProperty ...

  9. VS里的 代码片段(Code snippet)很有用,制作也很简单

    工欲善其事必先利其器,而 Visual Studio 就是我们的开发利器. 上一篇文章,介绍了一个很棒的快捷键,如果你还没用过这个快捷键,看完之后应该会豁然开朗.如果你已经熟练的应用它,也会温故而知新 ...

随机推荐

  1. C#—Nhibernate使用教程

    本篇文章,让我们一起来探索Nhibernate.首先我们去搜索Nhibernate下载地址,如下链接所示.该版本可能是最新版,我下载的4.0.4.GA.其中GA意思我没搞清楚.不过应该不重要.http ...

  2. Navicat Premium 12.1.20.0安装与激活

    一.Navicat Premium 12下载 链接: https://pan.baidu.com/s/1GgNbCPGahN-Z91f4dnQkBQ 提取码: 3q8f 复制这段内容后打开百度网盘手机 ...

  3. linux shell 中的数组的取值 遍历 替换 删除操作

    引言 在Linux平台上工作,我们经常需要使用shell来编写一些有用.有意义的脚本程序.有时,会经常使用shell数组.那么,shell中的数组是怎么表现的呢,又是怎么定义的呢?接下来逐一的进行讲解 ...

  4. BlockingQueue 阻塞队列(生产/消费者队列)

    1:BlockingQueue的继承关系 java.util.concurrent 包里的 BlockingQueue是一个接口, 继承Queue接口,Queue接口继承 Collection Blo ...

  5. 2019牛客暑期多校训练营(第七场) - C - Governing sand - 平衡树

    5 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 感觉该出14才对,取前k小写成了取前k大. 5 1 5 4 2 5 3 3 5 2 4 5 1 6 5 5 suf=55 res=0 a ...

  6. Python 函数知识总汇

    函数在一个程序起到很重要的作用,那么如何学好函数呢,那函数有什么内容的,总结一下函数的知识归类 1,函数定义 def  函数名(): print("...") 2,函数返回值 re ...

  7. Java Collection总结

    继续啊啊啊啊啊啊 7. collection基本用法 Collection: add(obj) remove(obj) size() isEmpty() contains(obj) iterator( ...

  8. .linux基础命令三

    一. 两台服务器免密登录: 1. 生成密钥 ssh-keygen的命令手册,通过”man ssh-keygen“命令查看指令: 通过命令”ssh-keygen -t rsa“创建一对密匙,包括公匙和私 ...

  9. vs code 同步

    vs code 同步需要在github上配置好gist id, 将gist id添加至setting.json中, 然后再在localsetting中设置access token,  gist id ...

  10. 阿里P8技术栈