Cesare
Cesare

Reputation: 9419

Where do I detect where the outlet is from in Xcode?

I downloaded a project from GitHub and I'm experiencing some problems when detecting where a referencing outlet comes from.

This is an UIImage called "backgroundImage".

img

This is a UIViewController called "WalkthroughPageContentViewController".

imgUI

"backgroundImages" has two outlets references, one of which is connected to the "WalkthroughPageContentViewController" UIViewController.

img2

But there isn't any @IBOutlet connection here.

img3

So where does the first referencing outlet come from?

Upvotes: 2

Views: 4089

Answers (1)

Matt Gibson
Matt Gibson

Reputation: 38238

I had a quick look at this project, and the answer is that the referencing outlet doesn't come from anywhere. It's broken. If you examine the destination, the you'll see that Xcode knows this is a problem:

Storyboard Error

And if you open up the WalkthroughPageContentViewController.swift file, and add an outlet called backgroundImage, then close and reopen the file, you'll find it's magically been linked back up to the Storyboard:

Magic!

So, I'd surmise that at some point, there was an outlet in the file called backgroundImage, which was hooked up to the Storyboard, but then it was later deleted, leaving the project in this state.

This is pretty common when editing projects in Xcode. The Storyboard connections are basically just stored in XML in the .xib file, and there's no magic two-way connection between them and the code at design time, so if you delete the lines of code that they point to, you'll end up in this state.

Upvotes: 4

Related Questions