Skip to content

Commit

Permalink
salvando alterações no favoritos #9
Browse files Browse the repository at this point in the history
  • Loading branch information
renanvs committed Mar 9, 2014
1 parent b528135 commit 0856e17
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions PaleoProject/PaleoProject/PaleoFoodManager/PaleoFoodManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0856e17

Please sign in to comment.