NSUnknownKeyException


#1

The exact error message I’m getting is

I understand that this should mean something along the lines of having some XIB file connection that isn’t correct. However there are no ! marks on my connections for the XIB file. In fact, this is a relatively new copy from the original/base homepwner directory and the datePickerVariable should not exist. In this specific project all I’ve done so far is add the class for DatePickerViewController with a blank XIB. I’ve linked the view to UIView on the XIB, there are no other objects on the XIB. The .h and .m files are all in their default state. I’ve implemented a button on DetailViewController and links it to

[code]-(IBAction)changeDate:(id)sender
{
DatePickerViewController *dpvc = [[DatePickerViewController alloc] init];
[[self navigationController] pushViewController:dpvc animated:YES];

}[/code]

The above error occurs when I push that change date button.

Some other bits that may be contributing to this. I’ve previously implemented this project using a subview that worked. I’ve either duplicated or renamed the directory that the project was originally in into another directory. I’ve duplicated the base/original project into this current directory that the other project was also named previously.

Original -> "Homepwner"
subview version -> “Homepwner” duplicate -> “Homepwner - chp 11 gold challenge” -> renamed/duplicated to "Homepwner - chp 11 gold challenge subview"
new version -> “Homepwner” duplicate -> “Homepwner - chp 11 gold challenge”

The reason I’m suspecting this, is because on another try to create this via navigation controller, the error was referring to a datePickerView key which was implemented in my subview version. Now this error pops up for a variable that I have implemented in the subview version as well.

If this is the cause of the error, what’s the proper way of duplicating/creating backup files for the projects and how can I “unlink” the variables that don’t exist in the current project?


#2

The issue is very likely between the XIB and header. If you are not seeing warning triangle icons in IB, then you can try a couple of things:

  1. Select the XIB in your project navigator. It’s easier to close the navigator and library and then open the assistant editor on the right . displaying the relevant header file, then bring up the File’s Ownerconnections menu (Right-Click). See if a warning shows up now. I notice, at least for me, that Xcode doesn’t refresh it’s current warning alert inspector 100% of the time. However, I do notice that sometimes opening the header in the assistant editor helps refresh linked connections (i.e. XIB -> Header).

  2. You can right-click the XIB file in the project navigator and choose Open As -> Source Code. After doing that, you get a bunch of XML. Bring up the find menu (Ctrl+F) and search for record. Starting from that point down, the connections should be listed (among other stuff). If you paste here the result of record down from the XIB’s source, along with the header file, they could be compared.


#3
  1. this didn’t show up anything different. No connections were made in the first responder’s for either my DetailViewController.xib or DatePickerViewController.xib

  2. I’m not sure what I’m looking for in here, if I do a search for datePickerVariable that doesn’t show up. I’ve starred the segment of code in DetailViewController.xib that has the changeDate button set up.

DetailViewController.xib

[code]



view



3



nameField



51



serialNumberField



56



valueField



57



dateLabel



58



delegate



61



delegate



62



delegate



63

*****

  •   			<object class="IBCocoaTouchEventConnection" key="connection">
    
  •   				<string key="label">changeDate:</string>
    
  •   				<reference key="source" ref="700791580"/>
    
  •   				<reference key="destination" ref="372490531"/>
    
  •   				<int key="IBEventType">7</int>
    
  •   			</object>
    
  •   			<int key="connectionID">70</int>
    

*****




0





1




9
0

9
1

0.0

1000

6
24
2



3
0

4
1

8

1000

6
24
3



5
0

5
1

20

1000

8
29
3



6
0

6
1

20

1000

8
29
3



3
0

4
1

8

1000

6
24
3



5
0

6
1

8

1000

6
24
3



5
0

5
1

0.0

1000

6
24
2



3
0

3
1

0.0

1000

6
24
2



6
0

6
1

0.0

1000

6
24
2



5
0

6
1

8

1000

6
24
3



5
0

5
1

0.0

1000

6
24
2



3
0

3
1

0.0

1000

6
24
2



3
0

3
1

103

1000

3
9
3



5
0

5
1

20

1000

8
29
3



6
0

6
1

20

1000

8
29
3



3
0

3
1

20

1000

8
29
3



5
0

6
1

8

1000

6
24
3



3
0

3
1

62

1000

3
9
3



5
0

5
1

20

1000

8
29
3



3
0

3
1

20

1000

8
29
3



5
0

5
1

20

1000

8
29
3













-1


File’s Owner


-2




4




7
0

0
1

60

1000

3
9
1





5




6




7





8




9




10





11




12




13





26





28




29




30




7
0

0
1

116

1000

3
9
1





31




32




34




35





36




38




39




42




44




47




48




53




54




55




64




7
0

0
1

118

1000

3
9
1





65




68




69






DetailViewController
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
UIResponder
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin























com.apple.InterfaceBuilder.IBCocoaTouchPlugin

com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin

com.apple.InterfaceBuilder.IBCocoaTouchPlugin

com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin




com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin

com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin




com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin




com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin

com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin





70

[/code]

My DatePickerView.xib

<object class="IBObjectContainer" key="IBDocument.Objects"> <array class="NSMutableArray" key="connectionRecords"> <object class="IBConnectionRecord"> <object class="IBCocoaTouchOutletConnection" key="connection"> <string key="label">view</string> <reference key="source" ref="372490531"/> <reference key="destination" ref="191373211"/> </object> <int key="connectionID">4</int> </object> </array> <object class="IBMutableOrderedSet" key="objectRecords"> <array key="orderedObjects"> <object class="IBObjectRecord"> <int key="objectID">0</int> <array key="object" id="0"/> <reference key="children" ref="1000"/> <nil key="parent"/> </object> <object class="IBObjectRecord"> <int key="objectID">1</int> <reference key="object" ref="191373211"/> <reference key="parent" ref="0"/> </object> <object class="IBObjectRecord"> <int key="objectID">-1</int> <reference key="object" ref="372490531"/> <reference key="parent" ref="0"/> <string key="objectName">File's Owner</string> </object> <object class="IBObjectRecord"> <int key="objectID">-2</int> <reference key="object" ref="975951072"/> <reference key="parent" ref="0"/> </object> </array> </object> <dictionary class="NSMutableDictionary" key="flattenedProperties"> <string key="-1.CustomClassName">DatePickerViewController</string> <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string key="-2.CustomClassName">UIResponder</string> <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> <string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> </dictionary> <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/> <nil key="activeLocalization"/> <dictionary class="NSMutableDictionary" key="localizations"/> <nil key="sourceID"/> <int key="maxID">4</int> </object>


#4

Not sure what brain fart made me say First Responder, I meant File’s Owner (edited my post to reflect that). :unamused: Try #1 again, but using File’s Owner

If that still doesn’t help, make sure to post the header files (.h) for the relevant XIB files you posted above. This helps by allowing a quick discrepancy check between them.


#5

DatePickerViewController.h

#import <UIKit/UIKit.h>

@interface DatePickerViewController : UIViewController

@end

DetailViewController.h

[code]#import <UIKit/UIKit.h>
#import “DatePickerViewController.h”

@class BNRItem;

@interface DetailViewController : UIViewController
{

__weak IBOutlet UITextField *nameField;
__weak IBOutlet UITextField *serialNumberField;
__weak IBOutlet UITextField *valueField;
__weak IBOutlet UILabel *dateLabel;

}

-(IBAction)changeDate:(id)sender;

@property (nonatomic, strong) BNRItem *item;

@end
[/code]

I’m more and more certain that this is an issue with how I duplicated the file. The variable, “datePickerVariable” is no longer in my current project. I’ve read something about manipulating the project’s UID but as I couldn’t follow the instructions (not sure what it was asking me to do) I decided to move on. I’ll still check this periodically to see if someone could explain it further but at this point, I’ll have move onto other projects.


#6

On the subject of duplicating files in order to create a backup of the project, utilizing the source control feature from xcode 4.6 seems to be the proper way. This article goes into depth of how to utilize it and it’s features.
http://www.raywenderlich.com/13771/how-to-use-git-source-control-with-xcode-in-ios-6


#7

[quote=“kaplyk”]On the subject of duplicating files in order to create a backup of the project, utilizing the source control feature from xcode 4.6 seems to be the proper way. This article goes into depth of how to utilize it and it’s features.
http://www.raywenderlich.com/13771/how-to-use-git-source-control-with-xcode-in-ios-6[/quote]

RayWenderlich is an awesome site for iOS that I also reference myself.

Looking at your XIB dump and header, I didn’t find an issue, so I re-read your problem and considering your changes to the original folders, which I find Xcode inconsistently tracks, makes me wonder if you’ve checked that your Sources match the expected location.

Bring up your Build Phases (click project header in navigator) and choose the Target. Under the Build Phases->Compile Sources section, you can view where it’s pulling the sources. I’d just right-click each and select Show In Finder.

What may have happened (because it has to me many times) is the following: When you copy a project or parts of it to another location, the Assistant Editor will sometimes still point to the original file from the original project. As you drag connections from your new XIB file to that header file, or even write code in it on the side, it may be changing the code in that original source. There’s a chance that even if you grab the correct source later, you can have verified connections in your XIB (as they point to that original source), but that outlet/action just doesn’t exist in your copied project.

Something you can do to stop this from happening is by making a reference change in the assistant editor. At the top, click the tuxedo icon (it’s the first icon after the left and right arrow icons). If it’s set to Automatic, change it to Manual. Follow the disclosure icon submenu to the full location of the correct file desired. There are other ways, but it’s good to know about some of the quirks of the current version of Xcode we’re using.