Writing code is fun but not an easy task. While writing code in Objective-C or Swift, if we could also perform some Xcode tasks swiftly, it would be so awesome.
Here I am listing some of the Xcode shortcuts which would definitely come handy. Or, you could still learn them if you want to project yourself as a pro among your colleagues.
Tagging your code is an awesome way to find a section or a part of code. You must try using special tags like "//MARK, //TODO and //FIXME". These tags will create a special section separator in your code.
Snippets. Did you know that you could save a code snippet in the snippets library so you can simply reuse them in your new projects? Copy-Paste is too old now. Isn't it?
If you want to open the drop-down with all the variables and method names, simply press ^ + 6. Also, when the drop-down is open you can simply start typing the method or variable name you wanted to go to.
If you want to add a placeholder field in any part of your code, just type <#placeholder#>.
Did you know that you can create a custom color in the assets catalog and use it in code or in the storyboard or Interface Builder directly? To do that, just right-click the assets folder and choose "New Color Set" and then adjust the RGB sliders to create your color. You can also name it and call it in the code as well by UIColor(named: "Color").
Press ⌘ + ⇧ + [ or ] to navigate between the tabs.
You are probably already aware of what ⌘ + F does. Now, if you press ⌘ + ⌥ + F, you'll have the find and replace option available.
If you hold the ⌥ key and drag over with the mouse to select a section of your code, you can edit all the selected lines simultaneously.
Open Quickly. Use the shortcut ⇧ + ⌘ + O to open any file or method in your project. If you add a colon ":", it will let you specify a particular line number.
Open your debugging window by using the shortcut ⌘ + ⇧ + Y.
Open the left navigator panel by pressing ⌘ + 0.
Open right navigator panel by pressing ⌥ + ⌘ + 0.
If you want to justify your code or give a proper good looking format to it, simply select the section of the code and press ⌃ + I.
To add documentation to your code, just select the part of the code and press ⌥ + ⌘ + /.
If you want to rename a variable or constant or a method name in its whole scope then select it and press ⌘ + ⌃ + E. Also, if you are using a Macbook with a touch bar, then this option is available in the touch bar too. It's really handy.
If you want to add multiple Auto Layout constraints in IB, you can do that by holding down the ⇧ key and click.
Hovering your mouse over a view if you hold down the ⌥ key, you can see its distance from other views.
If you want to quickly open the object library, press ⌘ + ⇧ + L.
If you want to open up the media library, press ⌘ + ⇧ + M.
Press ⌘ + L and type in the line number to quickly move to that line.
I wish you got to learn a few super awesome tricks and shortcuts today. They do make the coding hassle-free. It would be great if you comment on this blog a trick which I didn't mention here.