How to find the NIBs in a project that use a specific class?
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 al开发者_开发问答l 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:
Use find
find . -name '*.nib' -exec echo "{}" \; -exec grep MyView "{}" \;
Run the app until every NIB is loaded and see when the runtime complains in Console
Is there a better way to do this?
Yes, there is a better way to do this:
- Select the class name "MyView".
- In Xcode, select "Refactor..." menu item from the Edit menu
- Select the Rename from the popup, and enter the new name in the text edit field.
- Click the preview button. You should see all the files that will be affected by this change (including the nibs).
- Uncheck any files that were included that should not be (unlikely to happen-but it can).
- Click Apply and watch it update all the files so that it refers to your newly named class.
精彩评论