TexanJohn
TexanJohn

Reputation: 21

I can't connect objects from storyboard to controller

I have a project in Xcode (I'm relatively new to Swift).

I was adding objects (text fields and labels to my storyboard).

I started connecting the text fields and labels to the code (control+drag). I was able to perform this several times.

Now all of a sudden, I can no longer perform this action (connect an outlet to my code).

Add a screenshot of the error, although it simply looks like all the others posted.

I have closed the project, closed Xcode, deleted the text field (then re-added to storyboard), tried connecting. I have seen suggestions about Rebuilding the project (I have done that and can use the app on the simulator). I have seen suggestions about changing the Custom Class value of the text field, but that doesn't make sense to me and Xcode doesn't appear to allow that.

Somehow I have changed something that I am unaware of what I did. I have been messing with this for about an hour now. I have read many other posts here and on the web, but none of those methods have resolved my issue.

Upvotes: 0

Views: 386

Answers (2)

Antonin Charvat
Antonin Charvat

Reputation: 952

Deleting the derived data sure will work. However you may also write the @IBOutlet variable in the code first the same way Xcode creates it and then you should be able to simply connect the outlet to it.

Upvotes: 0

TexanJohn
TexanJohn

Reputation: 21

Apparently I needed to delete the "Derived Data" associated with my project.

Xcode -> Preferences -> Locations

Under Derived Data, use/select small arrow at the end of the path name to display the folder in Finder.

Close Xcode.

Then, delete that folder (or project specific).

After doing this, my problem was solved. I don't know what is in "Derived Data".

Upvotes: 0

Related Questions