How to rename UIViewController and its xib

I am using iOS 5 and Xcode 4.2 . In my project, I have a UIViewController with xib . Now I want to give a separate name for the UIViewController and xib .

Is it possible?

After changing the name of the UIViewController controllers that display a warning, and I can’t connect the connection controllers to this class.

+7
objective-c ios5
source share
4 answers

In the header file (SomeViewController.h) select the class name and in the Xcode menu> Edit> Refactoring> Rename

And follow the instructions on the screen.

Good luck.

+16
source share

Renaming class file names and interface files is possible . However, renaming the class name using the refactor option to Xcode is evaluated than manual execution.

To refactor GOTO: "symbol navigator (next to the project navigator)" β†’ right-click on the name of your file β†’ "REFACTOR" β†’ RENAME.

Having different names for the classes and the interface does not cause problems, but its standard supports the interface file name in the same way as the files of the corresponding classes.

+2
source share

You simply change the names of the .h and .m files by clicking on these files. Ever the new name you gave these files uses this name when importing these files other than those that do not change this name anywhere. try once ..

+2
source share

After changing the name of the UIViewController, the controllers showing and I cannot connect the connection controllers to this class.

Find the code in which you are creating the controller instance. It should look something like this:

 MyViewController *mvc = [[MyViewController alloc] initWithNibName:... bundle:...]; 

When you find this line, look at the values ​​you pass for the nib name and package. Most likely, you will need to change the name of the nib you are going through. Either you pass the wrong name, or pass nil . If in the first case, just correct the name. If you pass nil , just change this to display the actual .xib file name. (Normally nil used because the UIViewController will use the class name as the nib name if you pass zero, so nil is a convenient shortcut.)

+1
source share

All Articles