Xcode C ++和Objective-C重构 [英] Xcode C++ and Objective-C refactoring

查看:226
本文介绍了Xcode C ++和Objective-C重构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Xcode中有没有办法重构混合C ++ / Objective-C代码?我使用Cocos2D和Box2D编写一个游戏,而Box2D是用C ++编写的,所以每个类都应该有.mm的扩展名,因此当我尝试使用。重命名变量,我得到一条消息,如 Xcode只能重构C和Objective-C代码

Is there a way to refactor mixed C++/Objective-C code in Xcode ?? I am writing a game using Cocos2D and Box2D, and the Box2D is written on C++, so every class I write should have .mm extension and therefore when I try to e.g. rename the variable, I got a message like "Xcode can only refactor C and Objective-C code".

提前感谢!

推荐答案

Xcode非常受限于重构,甚至与简单Obj-C。它基本上是重命名,它甚至不能在评论中重命名。如果它说它不能做某事,那么它可能不能。

Xcode is VERY limited with refactoring, even with plain Obj-C. It's basically renaming and it can't even rename in comments. If it says it can't do something, then it probably can't.

重命名的唯一方法是使用 find&替换。注意Xcode可以处理正则表达式,所以它通常是足够好。

The only way to rename is using find & replace. Note that Xcode can handle regular expressions so it is often good enough.

当然,问题是find&替换不知道编程语言,有时可以添加一些额外的替换或忘记替换某些东西,因此要格外小心。

Of course, the problem is that find & replace doesn't know the programming language and sometimes can add some extra replace or forget to replace something, therefore be extra careful. Clean build is neccessary after every refactoring to check everything got renamed correctly.

您还可以使用命令行工具(例如 sed )来实现相同。

You can also use command line tools (e.g. sed) to achieve the same.

这篇关于Xcode C ++和Objective-C重构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆