XCode find and replace in project problem with XIB
I wanted to rename one badly named variable to something more naturally named (UITableView myListView --> myTableView). Did开发者_StackOverflow社区 that with XCode "Edit - Find - Find in project" and replaced all found 7 items with the new one. Application compiled ok, started and crashed.
After some debugging found out that there was one (1) old name remaining inside XIB file xml spagetti (IBConnectionRecord, IBCocoaTouchOutletConnection)!
Question: how should I rename variables? Is there something that works right away?
This is called refactoring and if you use the refactor tool that Xcode ships with, then also XIB variables will be renamed. Just highlight the variable/method you want to refactor, hit CMD
+ SHIFT
+ J
and you see the refactor window.
It's probably best if you do this from the .h
files.
To rename local variables use
- "Edit All in Scope"
As SanHolo already said, you could use
- "Refactor" -> "Rename"
to rename global variables.
精彩评论