Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove all references for outlet

I accidently set event for command button as "outlet" than "action". Due to auto-drag feature, xcode generated references in applicationDelegate and .h and .m files. I removed the entry from .h and .m files but simulator wont run because it is still looking for that missing reference. I could not find that outlet referred anywhere. I am fairly new to iOS programming. Can anyone suggest a solution for this?

like image 308
pbd Avatar asked Sep 08 '12 04:09

pbd


3 Answers

You have to unlink the outlet from the item in interface builder. Select the UI element that you linked the outlet to and then remove it in the "Connections Inspector".

enter image description here

Click the little "x" ^^^

like image 150
Mick MacCallum Avatar answered Nov 18 '22 02:11

Mick MacCallum


I think there are two different reasons that people may come here wondering how to get rid of an unwanted Outlet reference.

  1. Created an unwanted outlet while using the Interface Builder.
  2. Copied some Outlet code from another projects View Controller.

Both reasons are fairly easy to solve.

Unwanted Outlet in IB

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

Unwanted Reference in Code

If you copy the view controller code from one project into another project you will notice a strange thing happening with the outlet. It is referencing the view from the first project without you ever connecting any outlets!

enter image description here

If you left click the little circle and click the reference link you will even be taken to the storyboard view in the other project. Trying to figure out how to get rid of this reference can drive you crazy.

Well, the good news is that there is really nothing for you to fix. You didn't copy over some deep, hard to find referencing link. Xcode is just getting confused because the View Controller and the outlet name are the same in both projects. Basically just ignore what that little circle says. You can close the first project and Xcode will figure things out eventually. Use the methods in part one of this answer to see if a view in your current project has a referencing outlet or not.

No need to delete Derived Data. That doesn't solve the problem anyway. Just try opening both projects at the same time again and you will get the same strange behavior. The way I figured this out was to separately create two new projects that had view controllers with the same name and a referencing outlet with the same name. I never copied anything but Xcode showed one was referencing the other. Like I said, ignore it.

like image 31
Suragch Avatar answered Nov 18 '22 01:11

Suragch


It will be listed in the storyboard/xib as well, on the command button outlets.

Delete it from there as well, and you should be good.

like image 4
lnafziger Avatar answered Nov 18 '22 03:11

lnafziger