7

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

Is it Possible?

After changing the name of UIViewController the controllers showing warning and i can not connect connect controllers to this class.

j0k
  • 22,600
  • 28
  • 79
  • 90
AKS
  • 145
  • 2
  • 10

4 Answers4

17

Within your header file (SomeViewController.h), highlight the class name and from Xcode menu > Edit > Refactor > Rename

And follow the on screen instructions.

Good Luck.

Desdenova
  • 5,326
  • 8
  • 37
  • 45
2

Renaming a class file names and interface files are possible. However, renaming class name by refactor option on Xcode is appreciated than doing it manually.

For refactoring GOTO: "symbol navigator(next to project navigator)">> right click on your file name >> "REFACTOR">> RENAME.

Having different names for classes and interface do not bring up issues, however its the standard to keep the interface file name same as that of the corresponding class files.

thatzprem
  • 4,697
  • 1
  • 33
  • 41
2

You just change the .h and .m file names by click on those files. What ever new name you gave to those files use that name while importing those files other than that don't change those name any where. try it once..

kalyani puvvada
  • 496
  • 4
  • 12
1

After changing the name of UIViewController the controllers showing warning and i can not connect connect controllers to this class.

Find the code where you're instantiating the view controller. It should look something like:

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

When you find that line, look at the values you're passing for the nib name and bundle. Chances are, you'll need to change the nib name that you're passing in. Either you're passing an incorrect name, or you're passing nil. If if the first case, simply correct the name. If you're passing nil, again, just change that to reflect the actual name of the .xib file. (It's common to use nil because UIViewController will use the class name as the nib name if you pass in nil, so nil is a handy shortcut.)

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • I passed xib name and nil respectively. – AKS Sep 10 '13 at 09:58
  • Also remember to update the class of the view controller inside the .xib file. The `File's Owner` proxy icon represents the view controller -- select it and set it's class to the view controller's new class name. – Caleb Sep 10 '13 at 10:42