Renaming an outlet in Swift

EDIT: Since Xcode9, there's a refactor function; the new good method is the one in this answer


Since Xcode 6, you can look for your outlet names directly in the Find navigator (Cmd+3), it shows occurrences in your code and in your xibs and storyboards. It also works with actions.

Just search the name in the Find navigator.

enter image description here

You can see that the second result is a reference in a storyboard. You can replace one by one by clicking on each result and press Replace, or you can directly Replace All if you are sure you don't break anything.


Refactor > Rename...

Xcode 9 had many editor improvements including a feature that changes an outlet/action name in the code and storyboard from one place.

In the example Swift code below, right click on btnRequestCode, from the popup menu select "Refactor > Rename...", change the outlet/action name and Xcode changes it in the Storyboard also.

@IBOutlet weak var btnRequestCode: UIButton!

enter image description here

Tags:

Ios

Xcode

Swift