diff --git a/PaleoProject/PaleoProject/Custom/CutomView/PaleoFoodTableView/PaleoFoodTableView.m b/PaleoProject/PaleoProject/Custom/CutomView/PaleoFoodTableView/PaleoFoodTableView.m index 09af490..4f1d922 100644 --- a/PaleoProject/PaleoProject/Custom/CutomView/PaleoFoodTableView/PaleoFoodTableView.m +++ b/PaleoProject/PaleoProject/Custom/CutomView/PaleoFoodTableView/PaleoFoodTableView.m @@ -142,7 +142,8 @@ -(void)removeItemFromTableViewAtIndex:(NSIndexPath*)index{ NSArray *indexPathList = [NSArray arrayWithObject:index]; FoodItemModel *foodItem = [[PaleoFoodManager sharedInstance] findFoodItemByIndex:index AtList:foodList]; - foodItem.isFavorite = [NSNumber numberWithBool:NO]; + [[PaleoFoodManager sharedInstance] removeItemFromFavorites:foodItem]; + NSArray *types = [[PaleoFoodManager sharedInstance] getFoodTypeListWithFoodList:foodList]; NSDictionary *dic = [[PaleoFoodManager sharedInstance] getDictionaryWithFoodTypeList:types AndFoodList:foodList]; diff --git a/PaleoProject/PaleoProject/PaleoFoodManager/PaleoFoodManager.h b/PaleoProject/PaleoProject/PaleoFoodManager/PaleoFoodManager.h index c0b3c9f..0b9a327 100644 --- a/PaleoProject/PaleoProject/PaleoFoodManager/PaleoFoodManager.h +++ b/PaleoProject/PaleoProject/PaleoFoodManager/PaleoFoodManager.h @@ -31,5 +31,6 @@ -(NSDictionary*)getDictionaryWithFoodTypeList:(NSArray*)typeList_ AndFoodList:(NSArray*)foodList; -(FoodItemModel*)findFoodItemByIndex:(NSIndexPath*)index AtList:(NSArray*)list; -(void)removeAllFavorites; +-(void)removeItemFromFavorites:(FoodItemModel*)foodItem; @end diff --git a/PaleoProject/PaleoProject/PaleoFoodManager/PaleoFoodManager.m b/PaleoProject/PaleoProject/PaleoFoodManager/PaleoFoodManager.m index d19bce2..b585111 100644 --- a/PaleoProject/PaleoProject/PaleoFoodManager/PaleoFoodManager.m +++ b/PaleoProject/PaleoProject/PaleoFoodManager/PaleoFoodManager.m @@ -168,6 +168,13 @@ -(void)removeAllFavorites{ for (FoodItemModel *foodItem in favoriteList) { foodItem.isFavorite = [NSNumber numberWithBool:NO]; } + + [context save:nil]; +} + +-(void)removeItemFromFavorites:(FoodItemModel*)foodItem{ + foodItem.isFavorite = [NSNumber numberWithBool:NO]; + [context save:nil]; } @end