开发者

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:

  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?


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜