How to rename the class name in swift?

前端 未结 7 1964
攒了一身酷
攒了一身酷 2021-02-12 03:33

I am trying to rename the class name in swift but it gives me error Can\'t refector swift code. I want to know the best way to rename a file that will reflect in t

7条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-12 04:22

    EDIT: Starting Xcode 9 you're now to easily do it. Highlight the code that you want to rename, right click and choose refactor -> rename. Or you can also use the Editor menu on top of the Xcode and choose refactor -> rename.

    Solution Below XCode 9:

    1. click Find -> Find and Replace in Workspace

    1. Rename it, for example I am renaming ChatViewController with ChatVC then hit Enter. This usually rename the naming in storyboard too, So it's really convinient, but just double check if you want to really make sure it's changed.

    1. Lastly, Dont forget to rename the file itself in the project navigator

提交回复
热议问题