I accidentally created two outlets for the same UI element and, after realizing the issue, went on to delete both outlets from the code and the element (a label) that they were attached to.
Now I'm still getting the "The [name of outlet] outlet from the [view controller] to the UILabel is invalid. Outlets cannot be connected to repeating content."
I deleted the code that created the outlet and the element itself with just select+delete. Is there some other way I should have handled it and how can I fix it now?
Delete the outlets that may be causing the problem and control - click on the object in the storyboard and delete all of the connections using the x. Now, go back and reconnect the outlets and everything should work!
If you need help, check this out.
Related
Not sure what the problem is here, I've tried:
Cleaning, rebooting Xcode/Computer
Clearing Derived Data
Relinking outlets
I don't have this problem with any other outlets in any other views. Here are some photos:
https://imgur.com/a/2t3da
https://imgur.com/a/zikBq
EDIT: It was a really silly mistake -> misspelled the identifier in my tableView method. Thanks for all your help though!
Did you set your custom cell class in Identity Inspector?
Identity Inspector
Did you try delete outlet and drag outlet again?
Are you referencing to correct custom class? Double check this. I am often using another class unwillingly and than I realized that I am in wrong file.
I think its a normal behaviour, try loading your VC in the storyboard and add the assistant editor on the right. Mine does the exact same thing when i go to my code straight without loading the VC in the storyboard. Can you also show how you set the textLabel?
I renamed a class, which happened to have an outlet connection to a label called mainLabel in a storyboard file. When I run my program, it crashes and gives me the error: "this class is not key value coding-compliant for the key mainLabel".
Other SO answers have shown this to be caused by a bad outlet connection, so I removed the connection and removed any lose ends. When trying to reconnect the label to an outlet in my code, I get the error Could not insert new outlet connection: Could not find any information for the class named CourseTableViewCell
Other SO answers have provided solutions which I have tried and haven't worked including:
Deleting the reference to the file and re-adding it
Cleaning the project
Deleting the derived data folder
deleting the label and re-adding it
Dragging from the code to storyboard rather than vice-versa
I made sure that the correct file name was listed in the identity inspector, under "Custom Class". If anybody has any other ideas, please let me know!
I can provide more information if necessary.
The following steps are what you need to do to find existing IBOutlet / IBAction from and object. Be it label, button, etc. And how to remove it.
Open Main.storyboard. The Document outline window should be visible by default on the left of your storyboard window. If not, click the icon on left of the storyboard window, next to the View As: iPhone 7.
Select the object in storyboard, it's easier to find and then select it from the document outline of the storyboard.
Open the Utility window if not yet open on the most right side. Use shortcut key Cmd-Option-0 (command-option-zero), to toggle open/close of the utility window.
Open the connection inspector by click on right arrow icon (top right most icon). Remove any unwanted IBOutlet / IBAction or any other connection you want to remove by clicking on the x icon next to the connection.
Recreate the connection. You could also drag directly from the circle next to the element in the connection window for a particular object. Else add the connection the way you have been doing for now.
As for the Class file and other coding file. You could just comment out the lines that previously have IBAction or IBOutlet. And retype the same line manually (don't cut and paste). Add back the connection from storyboard, and you should be good. Don't forget to delete the lines you commented out that you don't need anymore.
I deleted one of my ViewControllers and its classes. There were a few outlets in them, and now errors for them won't go away.
Here's the error:
The quoteTimestamp outlet from the UIViewController to the UILabel is invalid. Outlets cannot be connected to repeating content.
Anybody have a possible solution/fix? Xcode bug?
try (CMD+SHIFT+K) to clean project for the next time.
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".
This is a UIViewController called "WalkthroughPageContentViewController".
"backgroundImages" has two outlets references, one of which is connected to the "WalkthroughPageContentViewController" UIViewController.
But there isn't any #IBOutlet connection here.
So where does the first referencing outlet come from?
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:
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:
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.
I'm getting the "not key-value coding compliant message".
I've had this several times in the past and know what it means and have always been able to resolve it, but I don't know why I'm getting it in this instance. All I've done is:
1) drag n drop a UILabel onto the main view:
2) Drag from the UILabel to view controller and get IB to insert and connect an outlet:
But when I run I get "this class is not key value coding-compliant for the key currentStatus.'"
Here's the connections:
Why is it not working, what is missing?
What you have shown is ok, check if you removed some outlet properties from your code file (.h) and forgot to remove their links from IB.