Is it possible to rename/refactor a class file and have it rename the actual file on disk? If so, how can I do this?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- back button text does not change
相关文章
- 现在使用swift开发ios应用好还是swift?
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- Popover segue to static cell UITableView causes co
Works for Xcode 4.2.1: select file in project navigator (default left panel) and press [tab]
If you renamed a file manually, and used Find and Replace to rename the class name, make sure the file is added to Compile Sources in Build Phases of your target, as it will probably be removed.
Choose Refactor->Rename nevan king's answer is also works fine on Xcode Version 7.0 beta (7A120f)
The safest way to rename files is to refactor the class name using Xcode's "Refactor" command. Using that command makes sure that your code is also updated anywhere that references the file or the class (including NIBs).
Right-click on the class name in the interface (
.h
) file, chooseRefactor->Rename
, and Xcode will guide you through the process, allowing you to preview changes before you commit to them.More details:
Right click on the class name (after
@interface
) and choose Refactor->Rename. For example, right click onViewController
in this code:Enter the new name for the class:
Xcode will let you review the changes before you commit.
You can also highlight the class name and use Xcode's
Edit->Refactor
menu, or even map it to a keyboard shortcut if you want.If you actually want to rename the file without affecting any code, click on the name in the Navigator pane (left pane), wait a second, then click again. The name will be highlighted and you can type in a new one. You can also delete from the Navigator, rename the file in the Finder and re-add it to your project.
By default, Xcode will rename a file when you rename it in either the file navigator (left hand outline view thingy) or when you use the inspector.