Midas
Midas

Reputation: 930

Entity is still not key value coding-compliant for the key, even after rebooting my dev Mac

    if (self.temp) 
    {
    NSDateFormatter *form = [[NSDateFormatter alloc] init];
    [form setDateFormat:@"dd/MM/yyyy"];
    dt1 = [form stringFromDate:[datePicker date]];
    [self.temp setValue:dt1 forKey:@"dateOne"];
    }
    else
    {
    NSDateFormatter *form = [[NSDateFormatter alloc] init];
    [form setDateFormat:@"dd/MM/yyyy"];``
    dt1 = [form stringFromDate:[datePicker date]];
    NSManagedObject *newGoalText = [NSEntityDescription insertNewObjectForEntityForName:@"Goal" inManagedObjectContext:context];
    [newGoalText setValue:dt1 forKey:@"dateOne"];
    }    

This is the code I have written to save the date as a string into my core data model. And I have created a single entity. Goal 'Goal' contain attributes 'goalText(String)', 'dateStr(string)' and 'dateOne(String)'. When the data is going to be edited the if condition works otherwise else condition works. That is the flow. So when I execute this code I am getting the error as "[ setValue:forUndefinedKey:]: the entity Goal is not key value coding-compliant for the key "dateOne".'". The first two attributes are successfully saved and fetched though.. And one more thing is that the third attribute is set from a different view.

I have rebooted the Mac as per the answer in this other question,but no result is getting.

Upvotes: 1

Views: 2301

Answers (3)

kalpa
kalpa

Reputation: 982

May be this is late post. But hope it will help some one.

I got this error recently. For me while changing Xcdatamodel I was missing with the key. I added the key in entity. Then it's working fine.

Upvotes: 0

Midas
Midas

Reputation: 930

I have solved. At one stage I deleted the name.xcdatamodel and created a new one with the same name. But the old one some how remains in my project. Deleting that old one solved my problem. Thanks for your help

Upvotes: 2

J M
J M

Reputation: 31

Not sure it will fix your pb or not, but last time i met the issue was because a messed up in the bundle. (Happened when i added a property on the coredata model, and regenerate the class from the model) the old model was still being used.

pretty much the same thing as explained in the question: Entity is not key value coding-compliant for the key

If not yet done try to clean the the derived data of your project from the organizer. This is what worked for me.

Upvotes: 1

Related Questions