shi
shi

Reputation: 286

How to maintain Interface and Implementation in separate files simultaneously in Xcode

I have several lines of code of a written class with Interface written in testclass.h and implementation written in testclass.m in Xcode. I wish when I update an entry in testclass.m, its counterpart in testclass.h can be updated automatically.

For example, I have an interface for following function in both testclass.h and testclass.m:

-(void)testfunction

And I modified its name to a different one due to some reason in testclass.m to:

-(void)another_test_function

If I want this code to run I need to manually change the entry in the header. Although I'm very new to programming but I can imagine it could be really frustrating if you are trying to modify something in a big program with a lot of different files invoking some modified entry name. I wish Xcode can auto-detect this change and modify the entry in the header file to -(void)another_test_function automatically.

Is there any way I can do that? All I know by searching the internet is that you can use a shortcut to "edit all in scope" but this only affect all the occurrence in the same file, not header file.

Upvotes: 0

Views: 79

Answers (1)

ravron
ravron

Reputation: 11221

Right-click the method name you would like to change (in either the header or the implementation file) and then select Refactor > Rename. You can then change the name of the method, and Xcode will show you what it will change.

If that looks good, you can accept the changes and you're done.

Upvotes: 2

Related Questions