I am just trying to wrap my head around core data. I have managed to load some data into it i applicationDidFinishLaunching but now I want to do something a little more complicated. When I unwind from view controller B back to viewController A, I want to send the recipeName from B back to A and then write it to core data. I get this error:
CoreData: error: Failed to call designated initializer on NSManagedObject class 'Recipe' 2013-11-01 19:10:07.886 RecipesWithCore[96409:70b] -[Recipe setRecipeName:]: unrecognized selector sent to instance 0x8c8cf40 2013-11-01 19:10:07.890 RecipesWithCore[96409:70b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Recipe setRecipeName:]: unrecognized selector sent to instance 0x8c8cf40'
This is my unwindToRecipes:
-(IBAction) unwindToRecipes:(UIStoryboardSegue *)segue{
DBKAddRecipeViewController *source = [segue sourceViewController];
NSString *rn = source.recipe.recipeName;
if (recipe != nil){
//Add the recipe to coredata
NSManagedObjectContext *context = [self managedObjectContext];
NSManagedObject *newRecipe = [NSEntityDescription
insertNewObjectForEntityForName:@"Recipe"
inManagedObjectContext:context];
[newRecipe setValue:rn forKey:@"recipeName"];
}
}
RecipeName
is not a property of your managed object subclass... – Petro Korienev