21

SO i have this

- (void)loadView {
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* databasePath = [documentsPath stringByAppendingPathComponent:@"ProxDeals.db"];
NSError *error;

BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:databasePath];
if (fileExists==TRUE) {
    [[NSBundle mainBundle] loadNibNamed:@"ProxDealsViewController" owner:self options:nil];
}
else {
    NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"ProxDeals.db"];
    NSLog(@"%@",defaultDBPath);
    success = [fileManager copyItemAtPath:defaultDBPath toPath:databasePath error:&error];
    if (!success) {
        NSAssert1(0, @"Failed to create writable database file with message '%@/.", [error localizedDescription]);
    }
    [[NSBundle mainBundle] loadNibNamed:@"UserRegistration" owner:self options:nil];
}

}

and this error:

 Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ProxDealsViewController 0x5f22160> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key givenName.'

I know that i don't do something wright in the initialization of the UserRegistration nib but i don't know how to fix this.

codercat
  • 22,873
  • 9
  • 61
  • 85
flaviusilaghi
  • 677
  • 3
  • 10
  • 27

5 Answers5

86

This usually means that something is trying to access the @property "givenName".

If you were doing something with IB, the usual cause is that you either:

  • deleted that property from the class, but haven't deleted the hookups in IB yet
  • OR: you have a File's Owner object set to the wrong class (check the properties - different depending which version of xcode you're using - to find the Class Name its set as. You probably copy/pasted a NIB file, and didn't change this field in the NIB), and you've hooked up an outlet for that class, but your actual File's Owner is something different
Adam
  • 32,900
  • 16
  • 126
  • 153
4

This issue usually appears when there is a mismatch between the IBOutlets in the NIB file and the .h file.

Make sure that you do not have any broken connections in IB (they usually appear with yellow and a warning sign next to them). Also, clean the project (Product > Clean in XCode 4) before building, you may have a stale compiled file.

clawoo
  • 791
  • 6
  • 14
3

It also happened to me after I had removed a UI element from the nib file and the corresponding IBOutlet from the view controller. Cleaning the project didn't solved it either.

Therefore I removed the folders within the DerivedData folder which is created by Xcode 4. Then it worked!

brutella
  • 1,597
  • 13
  • 26
2

If you have different storybord files and if you have outlet references with out outlets creation in your header files then you just remove the connections by right clicking on files owner.

Files owner->Right click->remove unwanted outlet connections over there. clean and run your project

Go through this for clear explanation. This class is not key value coding-compliant for the key

Narasimha Nallamsetty
  • 1,215
  • 14
  • 16
1

Sometimes, it is very annoying to remove the app from the device/simulator, especially when you have saved data and configuration.

To solve this issue, for every ViewController for which you removed the .xib, file add the following code:

-(NSString*) nibName
{
    return nil;
}
rayryeng
  • 102,964
  • 22
  • 184
  • 193
Eyal
  • 124
  • 2