removing a #property etc. generated by Storyboard and XCode - iphone

I'm trying to switch over to Storyboard from IB and code but got the following problem. Xcode created a #property with #synthesize and the viewDidUnLoad methods but I now don't need it and if I try to delete it, the code crashes. To make things worse, I in the meantime had connected it to a UIButton (I changed the class to allow this) by mistake. When it crashes, the code gives the message:
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[
setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key lock.'
The question is the following. Where does XCode put the code for this and what do I have to remove to get back to where I started from?

Sounds like you have a connection set up in your nib that uses that property. If you delete the property, you need to update your nib to not try and set it.

Related

App Crashes When Connecting a MapKit View using IBOutlet

When I add a MapKit View to my viewController using storyboards, the app runs as it should. The crash occurs as soon as I add an IBOutlet connection. The error I get is this Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7f9f36897080> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key managerDelivOverviewMapBG.' I've deleted and remade the connection a few times, but it keeps crashing whenever one is made. I have done this a few times in my app already, and this is the only place where I cannot add a connection to a MapView.
EDIT: For whatever reason, no fix I could find worked, so I attempted to move on and just not use a map view which is when I realized my problem wasn't with the map view at all, because no matter what connection I made to any element, the app still crashes, so I wound up deleting the whole view controller and remaking it, which although inelegant, solved the problem.
Is the ViewController Custom Class set correctly in the Storyboard?
Make sure you added it to the ViewController Custom Class and not to the View Custom Class.
Also, after changing it, make sure to delete the old #IBOutlet and add new ones.
You can also check all the outlets connected to the View Controller by right clicking it on the left panel of the storyboard.
If you see an yellow warning sign in any of your outlets it means that it lost the connection and you need to add it again.

iOS application runs on iPhone but not iPad

I'm trying to run my application on both my iPhone and iPad but whilst the application runs on the iPhone, when I run it on the iPad I get the following error:
Terminating app
due to uncaught exception 'NSUnknownKeyException', reason:
'[ setValue:forUndefinedKey:]: this class
is not key value coding-compliant for the key ipad_switch_view.'
I only have the one ViewController and my iphone and ipad storyboards are the exact same. They both have a single text view and a switch which I've linked both with the same method.
Is there any reason I can't think of why this is happening? I'm still very new to iOS programming.
Check your IBOutlet in your xib or storyboard
For example . You can see in below image.
In above image lblserverDateTime is not exist in outlet .So remove
that type of IBoutlet or add into your class..

Any time I use an outlet to connect to a label, my app crashes

No crashes until I connect the label. Any type of connection results in this:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x8d66200> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
Classes are hooked up in each View Controller.
What is going on?!
You forgot to set your custom class name in the XIB file (or one of the sections in the storyboard). It is still the default (UIViewController).
Check references of your outlets in your XIB, one of the outlets is probably referencing a property that does not exist anymore
In above image lblserverDateTime is not exist in outlet .So remove this
type of IBoutlet..

"this class is not key value coding-compliant for the key...."

for the past few days i keep on getting this error everytime i run a build in xCode:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x1dd4a1c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key playBtn.'
at the begining it was in something i have made.
than i deleted it and it was still there - in an object (like this playBtn here) that did not exist anymore.
and now - in every single app i am trying to debug.
if on my iphone or in the simulator - the same.
i just can't run anything now !!
*clean doesn't work ! *
what do i do? i can't work like this..
notice:
solved. it was a problem with the appdelegate.m
thanks for who helped.
Check your IBOutlet connections in your XIB
You said playBtn does not exists, so check if connection still exist for the same, They will show ! mark in place of dot in connections.
I bet that You've got your File's Owner stuff messed up in your xibs.One of your views is set up to be the playBtn of the the File's Owner. However, when it's time to unarchive the nib, the owner doesn't have an playBtn property, so the unarchiving is failing.
Two Things you can do :
1) Check your "Connections Inspector" tab for the view that's throwing the error.
Remove all the Outlet Connections and re-connect all the Outlets.
2)
GoodLuck !!!
The problem is that you are indirectly (presumably when one of your nibs is unpacked) calling -setValue:forKey: on your UIApplication.
You can reproduce this issue by creating a new empty iPhone project and adding the following line to your app delegate's -application:didFinishLaunchingWithOptions:.
[[UIApplication sharedApplication] setValue:[[UIButton alloc] init] forKey:#"playBtn"];
Without a backtrace or even a complete log, it's hard to be sure, but it looks quite likely that you are having the same issue that is described here.
I solved it.
it was a problem with the appdelegate.m with the uitabbar.
thanks for who helped and those who tried :)

Adding UINavigationBar to a UITabBarController

Ok so I actually got to add UINavigationBar inside a UITabBarController using the following tutorial: http://twilloapp.blogspot.com/2009/03/how-to-embed-navigation-controller.html
But now the issue is that whenever I add a new button inside one of the views it just crashes.
For example:
In the first view called FirstViewController I added:
IBOutlet UIButton *test;
Than I also created:
- (IBAction) doSomething:(id)sender;
I hook up the test button with the UI in interface builder. But when I run i get:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x3b12e80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key test.'
Not sure what's going on with this.
Does anyone know of a solution?
Also, does anyone know where can I find good pre-built templates for these kinda apps so I can just start working rather than editing and setting things up.
Thanks
When you unarchive the nib file at runtime, it's going to invoke setTest:aButton on your controller, which will redirect to setValue:aButton forKey:#"test". Since it's throwing an exception that it doesn't know what the key #"test" means, chances are you forgot to put the #synthesize test; in your FirstViewController.m file.