Question: I'm making this app with a tableview and stuff. I want to make a "Favorites"-tab, and in the detail-view I want to make a star-like button. I'm done with the "add to favorites" stuff and want to make it impossible to add a string to my favoriteViewController more than once. 

Basically, I want to check if my NSUserDefaults contains a certain string in its NSMutableArray that matches the indexPath.row in the table view. It's really hard to explain...

Here's a snippet out of the code. I want to check if the "indexPathRowString" already exists in favoriteKey, before adding it again.

```
-(IBAction)addToFavorite:(id)sender {
    NSMutableArray* alreadyFavourites = [[[NSUserDefaults standardUserDefaults] objectForKey:@"favoriteKey"] mutableCopy];
    [favoritedAlready addObject:indexPathRowString];
    [[NSUserDefaults standardUserDefaults] setObject:alreadyFavourites forKey:@"favoriteKey"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

```

I'm very thankful for answers, I really need to fix this! :)

Answer: 
You want [NSArray's](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html) `containsObject:`.

Because NSString implements the [NSObject](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html) Protocol method `isEqual:` to return `YES` for two strings of the same content, this method will work correctly for you with two different string objects of the same value.
you can check using

```
if (![favoritedAlready containsObject:indexPathRowString])
{
    [favoritedAlready addObject:indexPathRowString];
}

```