She*_*lam 76 iphone xcode refactoring objective-c renaming
是否可以重命名/重构类文件并让它重命名磁盘上的实际文件?如果是这样,我该怎么做?
nev*_*ing 165
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, choose Refactor->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 on ViewController
in this code:
@interface ViewController : UIViewController
Run Code Online (Sandbox Code Playgroud)
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.
如果您确实想要在不影响任何代码的情况下重命名文件,请单击"导航器"窗格(左窗格)中的名称,等待一秒钟,然后再次单击.名称将突出显示,您可以键入新名称.您也可以从导航器中删除,在Finder中重命名文件并将其重新添加到项目中.
一种方法:选择要重命名的文件,然后按Tab。我主要使用这个,但是,Xcode 有时无法重命名它。所以我接下来要做的是
另一种方法:选择文件。打开检查器区域(位于右上角)。然后打开文件检查器。在那里您将找到名称字段,您可以在其中编辑文件的名称。(参见屏幕截图)。
归档时间: |
|
查看次数: |
50755 次 |
最近记录: |