Xcode 只能重构 C 和 Objective-C 代码。如何在 Xcode 6中重命名快速类名?
我已经在 Xcode 6 beta 版本中创建了一个新的单视图应用程序项目。我想把 Swift 类从 ViewController.swift改成别的名字。但是当我选择 Refactor-> Rename 时,它会显示错误 Xcode can only refactor C and Objective-C code。
First things first, let’s rename our View Controller to be something more meaningful. Open up your ViewController.swift file and replace all references to ‘ViewController’ with our new name, ‘SearchResultsViewController’. Rename the file as well to SearchResultsViewController.swift.
If you try to run the app from here you’ll get a crash. This is because our storyboard file hasn’t been updated to know about the new class! So open up the Main.storyboard, select your ‘View Controller’ object in the scene (the left-hand side nav), and then select the Identity Inspector (right-hand side, third button.)
From here let’s change the class from ‘ViewController’ to ‘SearchResultsViewController’. Now we should be back on track. Check that the project still works, and let’s proceed.