in my previous question i was given some code in order to make up this statment.
favoriteArray is an Mutable Array...
if (![self.favoritesArray containsObject:@"added"])
{
[self.favoritesArray addObject:@"added"];
}
else
{
[self.favoritesArray removeObject:@"added"];
}
//NSUInteger newRow = [self.favoritesArray count];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:self.favoritesArray forKey:@"MyFavorites"];
however i can't get @"added"
to be removed...
when the app loads it automatically loads added in the favorites the added text even after cleaning the code.
when i press the button it doesnt remove it.
so im guessing there is something wrong
and here is where i load it...
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSMutableArray *didContain = [[NSMutableArray alloc] init];
didContain = [[userDefaults objectForKey:@"MyFavorites"] mutableCopy];
if ([didContain count] == 0) {
NSLog (@"zero");
//
// no favorites have ever been saved
//
} else {
// load the favorites into some array you synthesized just like before
self.tableFavoritesData = [[NSMutableArray alloc] init];
self.tableFavoritesData = [[userDefaults objectForKey:@"MyFavorites"] mutableCopy];
}