IOS development – learn to use code blocks to improve your development efficiency

IOS development - learn to use code blocks to improve your development efficiency
Coldplay

I believe that many developers in the initial stage when not remember the methods of all kinds of dilemma, so most of the time, when using the same control properties, suffer from not remember agent method variety, it can only follow written before the code and then copy it again, or slightly experienced developers in when the amount of code but slightly more frame is roughly the same, only slight few changes when the demand of copy written before the code fragment and make the appropriate changes, as in the daily “in development and improve the efficiency of the development” means, but often find before the code is a rather time-consuming things.

Original address —> MyBlog

However, fortunately, Apple Corp has long been considered for developers of this, in the Xcode for developers to prepare a shortcut – code block

A block of code, a lot of iOS development just to the novice may not know what this is, even have 2-3 years working experience in the developer did not use a block of code There are plenty of people who are. So what does this code block do?

I first to demonstrate the use of results, I believe we will be at a glance.


Now, I’m going to use a tableView in viewController, and need to use the method in the proxy protocol, so:

IOS development - learn to use code blocks to improve your development efficiency

Feel very magical, the efficiency of how, just 2 seconds (less than), finished several basically will be used in the tableView method of the agency agreement, only need to complete the fill no placeholder is complete, the efficiency is not fast, this is a block of code in the daily development function.


Now, we should be aware of the role of the code block, then let us look at how to use this code block.

A block of code, as the name suggests, the code framework is a “block” embedded, the code framework required written code blocks in advance, leaving only the possible change places with a placeholder instead, when used to press the corresponding code block out custom tags, fill in the required for the development of a character can be completed efficiently.

1 in the first place, we need to write the code we need in order to use the tableView proxy method I just used as an example:
#pragma mark - #pragma mark - tableView - (NSInteger) numberOfSectionsInTableView: (UITableView * tableView) {return 1;} - (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section < #expression {return; #>} - (UITableViewCell *) tableView: (* UITableView) tableView cellForRowAtIndexPath: (NSIndexPath * indexPath) {< #classCell#> cell; * = [tableView dequeueReusableCellWithIdentifier:< # (nonnull * NSString)]; #> return cell;} - (void) tableView: (UITableView * tableView) didSelectRowAtIndexPath: (NSIndexPath * indexPath) {} - (CGFloat) tableView: (UITableView * tableView) heightForRowAtIndexPath: (NSIndexPath * indexPath) {return < #expression#>} * * Note: placeholder writing format for < #name#> * *
2 write code, we find the lower right corner of the Xcode, such as the way to find the code block storage
IOS development - learn to use code blocks to improve your development efficiency
3 these are the places where we store the code block, Xcode has been prepared in advance some of the system comes with the method
IOS development - learn to use code blocks to improve your development efficiency
4 then, what we need to do is to put the code we write into the code block
IOS development - learn to use code blocks to improve your development efficiency
Title is the code you want to display in the store the name on the map marked is where you need to type it out for free, what can be, what what, of course, the shorter the better, this will be accomplished, the next need to use when you just play your initials this code, you come out
IOS development - learn to use code blocks to improve your development efficiency
6 try out of your new code block, as in the beginning I do, if the code block number can also be directly from the storage point directly drag it out, like the beginning of storage when do the same, but we are in turn out
7 If you need to modify the code block has been saved, so you only need to find the code block, then click it, click on edit, if you want to delete the code block, only need to select the code block, then tap the Backspace button, pop-up box select Delete to

Thank you for taking the time to read my article

You can use the code block?