在整个 xcode 项目中重构整个类名

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6823936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:34:04  来源:igfitidea点击:

refactoring a whole class name in whole xcode project

iphoneobjective-cxcode

提问by aherlambang

I just changed my class name from Group.h to CVGroup.h and therefore everything is affected in my code. Is it possible to refactor the whole project so that Group is refactored into CVGroup?

我刚刚将我的类名从 Group.h 更改为 CVGroup.h,因此我的代码中的所有内容都会受到影响。是否可以重构整个项目,以便将 Group 重构为 CVGroup?

回答by dtuckernet

In short, there is functionality that is supposed to do just that, but it doesn't always catch all of the instances. You can select the class name in the header file and then do Edit > Refactor > Rename and that will try and catch all of the instances (this is in Xcode 4). The nice thing is that it will let you see the diff's of where it was changed.

简而言之,有些功能应该做到这一点,但它并不总是能捕获所有实例。您可以在头文件中选择类名,然后执行 Edit > Refactor > Rename,这将尝试捕获所有实例(这是在 Xcode 4 中)。好消息是,它会让您看到更改位置的差异。

I will say from experience that this method usually missed several instances of the name, so a manual follow-up is almost always required.

我会根据经验说,这种方法通常会错过几个名称实例,因此几乎总是需要手动跟进。

回答by jaminguy

Have you tried the Refactor command? In your Group.h file highlight the class name and choose Refactor->Rename from the Context Menu. This will rename the class everywhere it is used in your application.

您是否尝试过重构命令?在 Group.h 文件中突出显示类名并从上下文菜单中选择 Refactor->Rename。这将在您的应用程序中使用的任何地方重命名该类。

回答by Michelin Man

The same as described above will work in Xcode 6.2: Select the class name in the header file and then Edit > Refactor > Rename.

与上面描述的相同在 Xcode 6.2 中也适用:在头文件中选择类名,然后选择 Edit > Refactor > Rename。