you should not check for selectors. Imagine a key called entity or managedObjectContext . The NSManagedObject class definitely responds to these selectors, but the best thing to happen if you try to assign something wrong is that your code crashes. A little less luck and something like this destroys the entire kernel data file and all user data.
NSEntityDescription has a method called attributesByName that returns a dictionary with your attribute names and the corresponding NSAttributeDescriptions . So these keys are basically all the attributes you can use.
Something like this should work:
Appointment *appointmentObject = [NSEntityDescription insertNewObjectForEntityForName:@"Appointments" inManagedObjectContext:[[DataManager sharedInstance] managedObjectContext]]; NSArray *availableKeys = [[appointmentObject.entity attributesByName] allKeys]; for (id key in dict) { if ([availableKeys containsObject:key]) {
source share