Elye
Elye

Reputation: 60271

Is there a clean way of converting outlet to action?

I am new to iOS, I hope to find a good way of doing so.

In the storyboard, we could Control and Drag a view over to the code, that automatically setup either Outlets or Actions. It's normally a combo selector away to change from Outlets to Actions.

However, many a times, I accidentally click okay and created an Outlet instead of Action. When this occurs, the change also happens on Storyboard xml file. I can't just delete the Outlet and recreate the Action.

My question is, is there a clean and quick way to undo my Outlet creation, or a quick way to convert to Action?

Upvotes: 2

Views: 147

Answers (1)

djromero
djromero

Reputation: 19641

I don't know any way to convert the outlet to an action. All you can do is revert the mistake quickly.

Adding an outlet will modify the storyboard XML adding something like:

<connections>
<outlet property="outletName" destination="7d6-0U-xzC" id="c7Y-gw-mKK"/>
</connections>

and the controller with:

@IBOutlet weak var outletName: UIBarButtonItem!

When you realize the outlet should have been an action you can press Cmd-z in the storyboard (the XML change will be reverted), then click on the controller editor view and press again Cmd-z (the source file will be reverted).

If you want to verify yourself that nothing else changed (and everything is reverted) making the mistake and then revert it on a project under source control after you have committed all pending changes.

Upvotes: 3

Related Questions