NSUnkownException : this class is not key value coding-compliant for the key piewTextField - iphone

I am developing my app for Deployment on ios5 with Xcode 4.6 .I have a singleview app i am creating simply a new objective-c class for a new View Controller
name 'PiewController' i have defined the PiewController.h file like this:
and my PiewController.m looks like this
and my PiewController.xib Looks like this
and the connections of File's Owner are:
and the Error it is giving when i have loaded PiewController Directly from AppDelegate
and the AppDelegate looks like

Hmm it seems you want to connect the PViewController's xib stuffs to the ViewController. The debug message, i think, can be interpreted as : there is no property like piewTextField in ViewController (which is true, since you defined it in pviewController). Are you sure you load the correct xib for pviewController and not for the default initialized ViewController in AppDelegate.m?

Turns Out i forgot to include PiewController in the AppDelegate
With the Following changes it works perfectly

Related

This class is not key value coding-compliant swift

Yes, there are several posts about this problem, but none of these seem to answer my problem?
I created a custom view in a nib file and connected it to code, exactly like here:
Link
Only differences:
My class is named EditorSectionView not CustomView
My outlet's name is customView, not contentView
Apart from the code, i did the following, as described in the gist:
In Interface-Builder, click on "File's Owner" and make the File owner's custom class "EditorSectionView", NOT the View itself
Drag and Drop the top level view (the "Custom view" named item from Interface Builder) to the EditorSectionView via Assistance Editor to create an outlet named customView.
Whenever i start the app and click on the button that should use this custom view, it crashes with the error:
"This class is not key value coding-compliant for the key customView".
However, when i have a look at the connections inspector, in my nib file, there is no "!" like some other posts pointed out and all seems to be fine.
I am using the nib file like that to instantiate it:
form +++ Section(field.name) {
let header = HeaderFooterView<EditorSectionView>(.nibFile(name: "EditorSectionView", bundle: nil))
}
This should create a new form section in Eureka, as described here: https://github.com/xmartlabs/Eureka/blob/master/README.md (Search for "You can use a Custom View from a .xib file:" in the readme).
I have tried to solve this for an hour now, but i don't know what else to do. All connections are set (the outlet, the class for the UI), the code itself copied from a gist, etc.
What am i doing wrong here?
Thanks.
EDIT:
If i set the custom class in the identity inspector as well to EditorSectionView, not only the File's Owner custom class to EditorSectionView, it doesn'T crash any more with "not coding compliant for key XY" but it crashes with EXC_BAD_ACCESS on the line i am calling loadNibNamed().
I found here the answer, that i should not set a custom class for the top level view, which will result again in "not coding compliant". So either way it still doesn't work...
Its difficult to tell without seeing what your connections are in the Xcode inspector, but sometimes if you connect an outlet and then rename it in your code, that outlet is still connected with the old name and you get a key-value compliance issue
Places to look are in the "User defined attributes table of your identity/inspector..
And also check your connections inspector

instantiateViewControllerWithIdentifier crashes app

I am trying to instantiate a ViewController defined in MainStoryBoard.storyboard using the code snippet shown in the pic below. I also assigned an identifier to the controller but app crashed with the error shown in pic saying "Storyboard doesn't contain a controller with identifier masterViewController" although you can clearly see in pic that its there.
Any help will be appreciated.
Just so you know, following solution didn't work for me: Crash with instantiateViewControllerWithIdentifier
Below is the snapshot that confirms that the storyboard object is same that is retrieved from viewcontroller and used to instantiateViewControllerWithIdentifer:.
SITUATION DESCRIPTION: I am trying to develop a custom SplitViewController (subclassed from UIViewController). This UIViewController is purely programmatic i.e. not based on IBInterface layout. However for its children i.e MasterViewController and DetailViewController I have made layouts in IBInterface. Now I am retrieving a UIStoryboard object in SplitViewController (purely programatic one) and passing it to a utility class shown here in the first pic that uses it to instantiate MasterViewController based on a layout in the Storyboard.
Hm, looks like if should work.
Try this:
Clean project and rebuild
Check if storyboard contains an instance of the correct storyboard
Fix by shaffooo (from comments below)
I rebuilt my storyboard and it fixed the issue I was having.
try to write the same name of your ViewController class into 'StoryBoard ID' in IB. Then edit the argument of your instantiateViewControllerWithIdentifier method with same string:
yourVCName *startingViewController = (yourVCName *)[self.storyboard instantiateViewControllerWithIdentifier:#"yourVCName"];

Unknown class ZBarReaderView in Interface Builder file

I am working on the ZBarReader and getting an error
Unknown class ZBarReaderView in Interface Builder file
[UIView setReaderDelegate:]: unrecognized selector sent to instance
0x6859f20
Please look at an attached image at here or below so that you can picture what I am doing so far :-
In the storyboard, I do have a view and its custom class is ZBarReadView. I also wire it with IBOutlet in header file. In m file, I do
viewReader.readerDelegate = self;
and the error is shown after right after that.
Can anybody please point out what I have screwed up....
I found the solution in a thread over here
You need to add the following code in your applicationDidLaunch in your AppDelegate:
// force view class to load so it may be referenced directly from NIB
[ZBarReaderView class];
Should be running fine after that.
you can also try to download 64bits ZbarSDK.
I think the solution should be to add -ObjC flag to "Other Linker Flags" section in your Build Settings. If you can't do this, e.g. you are using Parse Framework that doesn't allow you to set this flag, you will probably have to use the provided solution of Morothat: Set in your AppDelegate the following:
[YOURCLASSNAME class];
It looks like you actually added a view in interface builder and tried to call it a ZbarReaderView for IB to hook up. Correct me if I'm wrong but in this instance I don't think Ib is going to know what you mean by ZBarReaderView.
I'm Also assuming you haven't actually implemented the delegate method in your .m file.

iPhone Obj C - change startup root class?

I am learning iPhone Obj C slowly. I have a XIB with several views and all works well. I need to have a 2nd XIB to control another set of views but haven't been able to make it work.
So I created the 2nd class and a 2nd XIB, all called one.h one.m one.xib and the same for the new one is all two.*
As it didnt work I was going try and change the app to start on the TWO class rather than the ONE class. In the plist I changed the Main Nib base file but that didnt seem to do anything.
Where do you specify what the start up class is? That way I can make sure I did everything correctly first, and then go back to the code that is supposed to call the two class and xib.
Also if anyone has any sample code to go from one class and xib to another, please let me know.
thanks!
In your AppDelegate class make sure the ViewController being allocated and set to the window is the one desired.
Your project's [ProjectName]-Info.plist file decides which Nib file is used when the application starts, in the key NSMainNibFile. (By default, this is set to MainWindow.)
A standard MainWindow.nib file will define the "root" class, which is usually [ProjectName]AppDelegate. You can, however, change this by editing the nib.
I had to set the CLASS IDENTITY to the proper class for the app delegate on the XIB for both XIB.
Then I changed the plist to point to the XIB I wanted to start as root.
Both of the answers above helped me find this.
THANK YOU

iPhone app crashing with NSUnknownKeyException setValue:forUndefinedKey: [duplicate]

This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 7 years ago.
I'm writing my first iPhone app, so I haven't gotten around to figuring out much in the way of debugging.
Essentially my app displays an image and when touched plays a short sound.
When compiling and building the project in XCode, everything builds successfully, but when the app is run in the iPhone simulator, it crashes.
I get the following error:
Application Specific Information:
iPhone Simulator 1.0 (70), iPhone OS 2.0 (5A331)
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<UIView 0x34efd0> setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key kramerImage.'
kramerImage here is the image I'm using for the background.
I'm not sure what NSUnknownKeyException means or why the class is not key value coding-compliant for the key.
(This isn't really iPhone specific - the same thing will happen in regular Cocoa).
NSUnknownKeyException is a common error when using Key-Value Coding to access a key that the object doesn't have.
The properties of most Cocoa objects can be accessing directly:
[#"hello world" length] // Objective-C 1.0
#"hello world".length // Objective-C 2.0
Or via Key-Value Coding:
[#"hello world" valueForKey:#"length"]
I would get an NSUnknownKeyException if I used the following line:
[#"hello world" valueForKey:#"purpleMonkeyDishwasher"]
because NSString does not have a property (key) called 'purpleMonkeyDishwasher'.
Something in your code is trying to set a value for the key 'kramerImage' on an UIView, which (apparently) doesn't support that key. If you're using Interface Builder, it might be something in your nib.
Find where 'kramerImage' is being used, and try to track it down from there.
Also when you rename a view, don't forget to delete the reference on File's Owner. It may also raise this error.
Here's one where you'll get this error - and how to fix it. I was getting it when loading a nib that just had a custom TableViewCell. I used IB to build a xib that just had the File's Owner, First Responder, and the TableViewCell. The TableViewCell just had 4 UILabels which matched up to a class with 4 IBOutlet UILabels called rootCell. I changed the class of the TableViewCell to be rootCell. It worked fine until a made a couple of changes and suddenly I was getting the setValue:forUndefinedKey: when I was just instantiating the class after loading it from a nib:
NSArray * nib = [[NSBundle mainBundle] loadNibNamed:#"rootCell-iPad" owner:self options:nil];
cell = [nib objectAtIndex:0];
It failed at the first line, when the nib was trying to load. After a while, I noticed that it was trying to match the IBOutlet Labels to the root controller, NOT the rootCell class! That was my tipoff. What I did wrong was to inadvertently change the File's Owner to rootCell class. When I changed it back to NSObject, then it didn't try to match up to the delegate (rootController) when loading. So, if you're doing the above, make File's Owner an NSObject, but make the UITableCell your desired class.
I had this situation and it turns out even after finding all instances of the variable and deleting them my app still crashed. Heres what happened... I created another instance of a variable from a textfield from my XIB into my viewController.h but I realized I didnt need it anymore and deleted it. It turns out my program saw that and kept trying to use it in the program so in the future if this happens to anywhere else just go into you XIB right-click on the button or textfield etc and delete any extra unused variables.
I had this same problem today. I didn't have the right class specified for the View Controller in my Navigation Controller. This will happen often if you fail to specify the correct class for your views in Interface Builder.
You'll also get invalid selector issues as well. Always check your Interface Builder classes and connections!
This is how i solved mine, in Interface builder right-click the View Controller, there should be an exclamation mark on the missing outlet or action method. Find and remove all the references and that solved it.
This happened because i deleted the action method in the .m file.
It seems you are doing
#interface MyFirstIphoneAppViewController : UIViewController<> {
UIImageView *InitialkramerImage;
}
#property(nonatomic,retain) IBOutlet UIImageView *InitialkramerImage;
Then after synthesizing that imageview, When you open "MyFirstIphoneAppViewController.xib" in Interface Builder, you are taking an Image View from Tool(menu)/Library den linking that outlet to the 'InitialkramerImage' from the Files Owner of "MyFirstIphoneAppViewController.xib". Then you saved the project. But after that you might change the name of the outlet variable "InitialkramerImage" to "kramerImage". So, after doing this
#interface MyFirstIphoneAppViewController : UIViewController<> {
UIImageView *kramerImage;
}
#property(nonatomic,retain) IBOutlet UIImageView *kramerImage;
and saving the project when you run it, There is no existance of the outlet of "InitialkramerImage" in the "MyFirstIphoneAppViewController.xib". So, when you run the project there will be no outlet referencing from Imageview to the 'kramerImage' and
"For displaying the view,
UIViewController will try to find the
outlet to "InitialkramerImage" which
is not existing."
So, It will throw the "NSUnknownKeyException".
You can check the missing outlet by
opening the nib(.xib) file then right
clicking on the 'Files Owner' of that.
If you have done this code somewhere else and had a zip/compressed file, try to extract it again. It may work I dont know why but I feel like it is an extraction issue.
or you can try to change the IBOutlet to kramerImage and bind it again in NIB.