In this series of articles, I am going to mention few shortcuts that I hope would help you become more efficient while working with Xcode.
The mentioned shortcuts are the default ones that are provided by the Xcode 7.3 (7D175). You can always change the key mappings from Xcode -> Preferences -> Key Bindings option. ^ - Control Key ⌘ - Command Key ⇧ - Shift Key ⌥ - Option/Alt key ⏎ - Enter key
Edit all in scope (^⌘E):
Imagine you get to a maintain an iOS project which was previously maintained by a team of non-native english speaking developers. While maintaining, you find that the developers have used “TableView” as variable name for the UITableView. Being perfectionist, it bothers you that the variable name is “TableView” instead of your preferred name “tableView”. After thinking a bit, you feel that you can find & replace all the occurrences of “TableView” with “tableView”. Pretty easy, right? Below screencast shows how this would work.
Did you spot the problem with this approach?
The “find & replace all” action also alters the “UITableViewDelegate” class name to “UItableViewDelegate” since it contains the keyword “TableView”. So it updated the “UITableViewDelegate” to “UItableViewDelegate” and Xcode is not able to resolve this protocol name. So, what we can do? Better keep the variable name as “TableView”? No. This is where the Edit all in scope command comes to rescue.
The way edit all in scope works is you select the word that you would like to replace and press ^⌘E. This will highlight all the occurrences of your selected word in the current file. Any changes you make to the word will automatically be reflected in all occurrences of that word. Below screencast shows how this would work if we wanted to replace our variable name from “TableView” to “tableView”.
Hope this article would help you save some hassle while editing the variable names in Xcode.