I want to add an automatic favorites feature that works like this:
I have a detail view with a cell name and a unchecked star. User taps on the unchecked star, star is checked and the specific cell name is added to another view. At anytime the user can go to the detailview and tap the star again and the star becomes unchecked and the cell name is deleted from the other view.
I want to do this with a custom button as the star and a tableview as the other view. Preferably using an IBAction or an IBOutlet.
My Code for my button in my detailView
-(IBAction)toggleFav:(UIButton *)sender {
if([sender isSelected]){
//...
[sender setSelected:NO];
NSMutableArray *array = [[[NSUserDefaults standardUserDefaults] objectForKey:@"valueSaver"] mutableCopy];
[array removeObject:[NSString stringWithString:self.selectedSushi]];
[[NSUserDefaults standardUserDefaults] setObject:array forKey:@"valueSaver"];
[array release];
} else {
//...
[sender setSelected:YES];
NSMutableArray *array = [[[NSUserDefaults standardUserDefaults] objectForKey:@"valueSaver"] mutableCopy];
[array addObject:[NSString stringWithString:self.selectedSushi]];
[[NSUserDefaults standardUserDefaults] setObject:array forKey:@"valueSaver"];
[array release];
}
}