iOS programming Code Snippet Library

iOS programming? Code Snippet Library?

The freebie code comes from the code snippet library.

代码来自code snippet library。

Notice that there are a number of code snippets available

有许多code snippets available .

Click the Edit button on the code snippet detail window

点击Edit 按钮。

技术分享

The Completion Shortcut field in the edit window shows you what to type in a source file to have Xcode add the snippet.

Completion ShortCut 告诉你输入什么将会有这个片段。这个里面是init 。

This window also tells you that this snippet can be used in an Objective-C file as long as you are in the scope of a class implementation.

还能告诉你这个片段能用在Objective-C文件中。且在类实现的范围内。

?

You cannot edit any of the pre-defined code snippets, but you can create your own.

你不能编辑所有预定义的code snippets,但是你能创建你自己的。

?

locate the implementation of tableView:numberOfRowsInSection:. Highlight the entire method:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{
return [[[BNRItemStore sharedStore] allItems] count];

}

?

Drag this highlighted code into the code snippet library. The edit window will appear again, allowing you to fill out the details for this snippet.

把选中的部分拖到code snippet library . edit window 将会再次显现。

In the edit window, modify the code snippet so it looks like this:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{
return <#number of rows#>;

}

技术分享

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。