views:

38

answers:

1

Suppose I have a view derived class named MyView. In the same Xcode project MyView is defined, I have many NIBs. Some of the NIBs have a Custom View with the class set to MyView.

Now suppose I want to change the name MyView to something else or rename an outlet. I need to find all NIBs using MyView so I can update them.

My question is: What is the best way to find all NIBs using MyView?

The methods I've thought of are:

  1. Use find

    find . -name '*.nib' -exec echo "{}" \; -exec grep MyView "{}" \;

  2. Run the app until every NIB is loaded and see when the runtime complains in Console

Is there a better way to do this?

+7  A: 

Yes, there is a better way to do this:

  1. Select the class name "MyView".
  2. In Xcode, select "Refactor..." menu item from the Edit menu
  3. Select the Rename from the popup, and enter the new name in the text edit field.
  4. Click the preview button. You should see all the files that will be affected by this change (including the nibs).
  5. Uncheck any files that were included that should not be (unlikely to happen-but it can).
  6. Click Apply and watch it update all the files so that it refers to your newly named class.
Lyndsey Ferguson
Doh! I don't know why I didn't think about that. Thanks!
Doug Richardson
It isn't Monday, it must be the beer :)
Lyndsey Ferguson