I am using Daniel Gindi's Charts library.
I have a ViewController in my app that is a scrollview, and it is supposed to display 4 line charts on different axes (i.e they are in different UIViews), and because the lineCharts themselves are quite big, I put them in a ScrollView to ensure that the graphs can be seen clearly.
Before connecting the UIView to the ViewController, the app works fine. I could scroll the page as expected, and also the LineChartView looks fine, it just displays "No Data to Show"
However, I realised my app crashes after trying to debug my failing ViewController. I realised I could not even add the IBOutlet for the LineChartViews into my ViewController. I tried it with one and it gives an NSUnknownKeyException, and the problematic part of the code is the IBOutlet. I have made sure all my connections are clean, in fact I rebuilt the storyboard to make sure everything was fine and it still crashes when I establish an IBOutlet.
There isn't much code involved as it just involves establishing an IBOutlet with the relevant ViewController. I saw in another post that adding chart.translatesAutoresizingMaskIntoConstraints = false might help and it did not.
The error is:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key chiller1Trend.'
You cannot use chiller1trend as anIBOutlet and as a Cocoa binding key. You need to do one thing or the other, not both, because if you use bindings you don’t need that outlet. Thus, either remove that outlet from the view controller class code or select the UIControl to which chiller1trend is bound in the bindings inspector in your storyboard or xib file and delete that Cocoa binding. Do not forget to check if the module of your controller is also well set.
Related
I am running XCode 7.1 and running on device(iOS 9) - (not simulator). I am loading up a nib file by name as such:
MyDetailsViewController *myDetailsVC = [MyDetailsViewController initWithNibNamed:#"MyDetails" withNotificationCenter:notificationCenter];
this is simply just a class method that i have set up that loads up the xib via the mainBundle. The xib file is just a UIView with a tableview inside of it everything seems to be hooked up properly. However, when loading the nib(viewWillAppear, viewDidLoad etc hasn't executed yet) from the bundle I get the error:
NSUnknownKeyException, reason: '[MyDetailsViewController setValue:forUndefinedKey:]:This class is not
key value coding-compliant for the key tableView'
I know that I am not getting back some generic view controller because it spells out very clearly what view controller we are talking about. The File Owner seems to be hooked up properly and its Custom Class is set to MyDetailsViewController. Even when I hover over the IBOutlet 'circle' in code the tableview highlights as well as when i hover over the menu when checking the outlets.
Something that may be totally unrelated is the internal error message in the xib file, it may or may not be related to my problem and i've never seen it before. The beginning of the log file that you get from that error is:
Can anyone help me determine what is going on here? I would appreciate it.
here are a few more screenshots:
Before init you should call alloc first:
// MyDetailsViewController *myDetailsVC = [MyDetailsViewController initWithNibNamed:#"MyDetails" withNotificationCenter:notificationCenter];
MyDetailsViewController *myDetailsVC = [[MyDetailsViewController alloc] initWithNibNamed:#"MyDetails" withNotificationCenter:notificationCenter];
I'm using XCode6 beta and trying out Swift. When I put some auto layout constraints in a view controller the app crashes with the following error:
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named IBNSLayoutConstraint'
You're getting this error because you've set a constraint to an IBOutlet that is removed at runtime. This happens when you set the constraint to be a placeholder in Interface Builder. Since the constraint is removed, when it goes to unarchive it, it throws an error saying it can't do so.
There are two ways to correct this.
Method 1
Right-click on your Storyboard > Open As > Source Code
In the opened storyboard xml, search for placeholder="YES".
You'll find constraints that are set to be removed at runtime. Remove the placeholder attribute from the constraint, save and close.
Run the app and your problem should be fixed.
Method 2
Find the constraint that's causing your problems in Interface Builder. Uncheck the Placeholder option in the GUI. This should be one of the constraints that's set to an IBOutlet in the ViewController that's causing your crash.
This is what it should look like:
Alternative
Assuming you actually want the constraint to be a placeholder, then you'll need to remove any referencing outlets. To do this, select the constraint that you wish to be a placeholder. Then open the connections inspector (the button furthest to the right that looks like this: (->) ) and then remove any referencing outlets that may exist on that constraint.
I had the same problem just now and the following worked for me.
I released a working version of my app to the App Store, came back to work on it again a few days later tapping onto one my tabs in the UITabBarController it crashed with the error:
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named IBNSLayoutConstraint'
I didn't have any placeholder layout constraints that I was aware of or constraint outlets that shouldn't have been defined.
The solution for me was to simply turn size classes off and keep size class data for iPhone (App is only for iPhone). This must've deleted anything I'd missed in the size classes. I want size classes so I turned them back on and the app just worked again.
This might not be necessarily a constraint problem. For me it was caused by not having checked "Installed" for a size class that was applying to my layout, see here
There was some problem with using size classes. I disabled that option from the storyboard properties and use only auto layout. It wasn't such a big problem since the app is iPhone only.
What ended up happening to me was that I cut a subview inside of Interface Builder to copy it into another xib. This left the subview in original xib Interface builder with it being greyed out. After removing the subview from it's original place (by selecting and deleting). I was able to get rid of the error.
There is an option in the inspector window when you select the xib file that will not use the constrains under "Show file the inspector" in the inspector called "Use autolayout".
I made a change to a scroll view so that it would let the picker controls embedded in it work properly using a solution I found elsewhere in Stackoverflow.
My new storyboard simply added these attributes to the scroll view, which seemed fine to me.
delaysContentTouches="NO" canCancelContentTouches="NO"
But in addition, I saw in my storyboard in another scene the following new fragment:
<variation key="default">
<mask key="subviews">
<exclude reference="86H-aM-wei"/>
</mask>
</variation>
I have no idea where it came from. At first I ignored it because everything seemed to work find on my dev machine. But when the build was built as Release and tested, I got the crash. Removing that spurious(?) fragment fixed the crash and has not seemed to impact anything else.
I had this issue when I had a button in a custom UICollectionViewCell, and had some of its constraints as IBOutlets on that class. I moved the button from the cell to the parent view controller and the IBOutlets were still referenced in the cell but didn't actually exist on the cell so blew everything up. Just needed to remove those IBOutlets and everything worked fine again!
So i started with my app with 2 buttons in my calenderview : a day and a week button.
Now i want to just use 1 button and dynamically change the name of it (that part works)
I am using the weekbutton for that. But now I want to remove the day button.
But i cant get it out of my program.
I tried first deleting the link in .xib
Then i delete the button.
Then i remove it from the .h file, and then from .m
It always results in the same error :
* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key dayButton.'
Cant see why i just cant remove the button...
You`ve deleted outlet from code .h/.m file, but somewhere in .xib something is still connected to deleted outlet. Recheck all connections in .xib file to be sure that they have appropriate declaration in .h file.
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.
I get runtime error when displaying EditViewController from my main view controller:
'[<EditViewController 0x7fbef90> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key saveChanges.'
I've done all the different Google/Stack Overflow searches I can think of and all of my results refer to either a Tab Bar or a bad connection in Interface Builder. My project has no tab bar and I removed every connection (except that from the File's Owner, EditViewController, to the view) from every object in my nib. EditViewController does, in fact have a method named -(IBAction)saveChanges.
It's driving me crazy, and I can't figure out what on earth I'm supposed to do. Thanks in advance.
You may not have any invalid connections from the top view to an IBOutlet but check the File's Owner and First Responder for possible IBAction's that have a connection to a method that is commented out or doesnt exist.
Another idea is to manually disconnect and reconnect each connection. I have experienced issues where I change an IBAction method from - (IBAction)doStuff to - (IBAction)doStuff:(id)sender after connecting in the IB but the connection still says doStuff when it should say doStuff:. That colon doesnt look like much (and its hard as hell to distinguish in the IB) but it changes the action to #selector(doStuff) which is targeting a method that doesnt exist.
Reconnecting couldn't hurt and has become my first troubleshooting step for most xib issues.
Another sure way to find it is grep (from Terminal):
[ 22:20 jon#host ~ ]$ grep -RH "saveChanges" /path/to/${PROJECT_DIR}/*
I found this issue when trying to add connection to a nib that was for a UITableViewCell.
The File's Owner was set to a custom UITableViewCell class. But rather than that, do as usual: draging from the views directly into the .h file you must set the class of the UITableViewCell object. Then, connect things to that object; not the File's Owner (even though they are the same custom class underneath).
I solved the problem, but if you're having the same issue I would recommend trying any of the above methods first because mine is time consuming. I moved EditViewController.h/.m/.xib to my desktop and created new EditViewController.h/.m/.xib. I then rebuilt the xib by hand and copy/pasted the code from the original into the new one. Thankfully my xib wasn't too complicated.