I need to check if an NSEntityDescription
key exists before trying to set the value. I have a dictionary of data from JSON and don't want to try setting keys that do not exist in my object.
Appointment *appointmentObject = [NSEntityDescription insertNewObjectForEntityForName:@"Appointments" inManagedObjectContext:[[DataManager sharedInstance] managedObjectContext]];
for (id key in dict) {
// Check if the key exists here before setting the value so we don't error out.
[appointmentObject setValue:[dict objectForKey:key] forKey:key];
}