zoukankan      html  css  js  c++  java
  • Xcode6中使用Code Snippet在Xcode中添加代码段

    通过code snippets,我们可以创建一些可重用的代码块,并且在任何需要的地方很容易的就可以使用这些代码块。这可以节省输入需要的操作和时间。并且,一旦你 学会使用code snippets,会发现你可以创建并扩充自己的code snippet library。
     
    1、创建一个code snippet非常简单。首先,打开Xcode并在utilities panel中选择code snippet library。

    2、将写好的代码直接拖入Code Snippet,注意红框内淡淡的字样

    3、随即会自动弹出提示框,可以更改对应内容,以便使用(Title为code snippets标题;Completion Shortcut为快捷输入)

    任何时候,你都遇到重复输入的相同代码块,都可以考虑将其添加到你的code snippets library中。
     
    下面是我经常使用到的一些snippet:
     
    1     Title: Animation Block 
    2     Completion Shortcut: ab 
    3     Completion Scopes: Function or Method 
    4       
    5     void (^<#Title#>)(void) = ^{ }; 
    1     Title: Animation Completion Block 
    2     Completion Shortcut: acb 
    3     Completion Scopes: Function or Method 
    4       
    5     void (^<#Title#>)(BOOL) = ^(BOOL finished) { }; 
    1     Title: Notification Add 
    2     Completion Shortcut: na 
    3     Completion Scopes: Function or Method 
    4       
    5     [[NSNotificationCenter defaultCenter] addObserver:<#Observer#> selector:<#Selector#> name:<#Name#> object:<#Object#>]; 
    1     Title: Notification Remove 
    2     Completion Shortcut: nr 
    3     Completion Scopes: Function or Method 
    4       
    5     [[NSNotificationCenter defaultCenter] removeObserver:<#Observer#> name:<#Name#> object:<#Object#>]; 
    1     Title: NSLog 
    2     Completion Shortcut: log 
    3     Completion Scopes: Function or Method 
    4       
    5     NSLog(@"<#Log#>"); 
    1     Title: Private Interface 
    2     Completion Shortcut: pi 
    3     Completion Scopes: Top Level 
    4       
    5     @interface <#Title#> () 
    6       
    7     @end 

     1 Title: Property Assign

    2 Completion Shortcut: pa

    3 Completion Scopes: All

    4  @property (assign, nonatomic)  

     1 Title: Property Strong

    2 Completion Shortcut: ps

    3 Completion Scopes: All

    4  @property (strong, nonatomic)  

    1     Title: Property Unsafe Unretained 
    2     Completion Shortcut: pu 
    3     Completion Scopes: All 
    4       
    5     @property (unsafe_unretained, nonatomic) 
     
  • 相关阅读:
    Python入门-函数进阶
    Python入门-初始函数
    Leetcode300. Longest Increasing Subsequence最长上升子序列
    Leetcode139. Word Break单词拆分
    Leetcode279. Perfect Squares完全平方数
    Leetcode319. Bulb Switcher灯泡开关
    Leetcode322. Coin Change零钱兑换
    二叉树三种遍历两种方法(递归和迭代)
    Leetcode145. Binary Tree Postorder Traversal二叉树的后序遍历
    Leetcode515. Find Largest Value in Each Tree Row在每个树行中找最大值
  • 原文地址:https://www.cnblogs.com/spring286/p/4169284.html
Copyright © 2011-2022 走看看