Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Interface Builder - "correct" way to delete/rename miswired IBOutlets / IBActions?

I am new to Xcode, working through Swift, so I'm not sure if what I am decribing is actually a bug.

When using interface builder and the assistant editor, I can create lables, buttons etc, and create Outlets and Action in the code with a control-drag.

So long as I am perfect, no problem. But I seem to run into problems if, for example, I make a mispelling of the object name. Or, I choose outlet instead of action. I can't seem to find a way to make a correction that does't seem to totally screw up the IDE. Even if I delete the object in the IB and the code, it seems to leave problems behind when I build. Or, if I try to delete the line in code and re-drag it, a new line of code is created, but the object seems to now reference the new name, and the old, now missing name.

Again, I am working with Swift --- Since I don't use/know Objective-C I don't know if there is a similar behavior using that language.

Appreciate any pointers. (Other than don't use the Interface builder / storyboards / Swift.)

like image 254
dave_the_dev Avatar asked Jul 02 '14 04:07

dave_the_dev


People also ask

How do I remove an IB outlet?

Select the view on the storyboard and then click the Connections Inspector. Then you can click the little x to remove an outlet reference.

How do you delete an object in Xcode?

Select all objects you want to delete, then choose Edit > Delete in the Environment menu bar (or press Delete).


3 Answers

Use the Connections inspector to break the connection. Then you can modify/delete the object and/or the code without having to worry.

enter image description here

like image 165
user3386109 Avatar answered Oct 11 '22 16:10

user3386109


The accepted answer is fine, but there are a few ways to do the same thing.

Method One

Right click the view in the storyboard and then click the little x by the referencing outlet.

enter image description here

Method Two

Right click the view name in the Document Outline. Then click the little x by the referencing outlet.

enter image description here

Method Three

Select the view on the storyboard and then click the Connections Inspector. Then you can click the little x to remove an outlet reference.

enter image description here

Extra References in Code

enter image description here

If you are getting outlet connections in code that you didn't add yourself see this answer.

like image 41
Suragch Avatar answered Oct 11 '22 14:10

Suragch


You can find unused IBOutlets in the file in which they're declared by looking in the "gutter" of the source editor for an "unfilled hole".

enter image description here

like image 7
Ron Fridman Avatar answered Oct 11 '22 16:10

Ron Fridman