NSSet/NSMutableSet. When/how to use?


Can someone provide a very simple example of using an NSSet / NSMutableSet?

Is the return value for NSSet a BOOL value?


I found my answer

 //Declare a Set
        NSSet *setOfHats = [NSSet setWithObjects:@"OrangeHats", @"RedHats", @"GreenCaps", @"OrangeTie", @"realOrange",@"blackTie", nil];
        // run an "objectsPassingTest" method with testing arguments that get passed to the comparison instructions below       
        NSSet *testSet = [setOfHats objectsPassingTest:^(id obj, BOOL *stop) {
            //initialize "testResult"value
            BOOL testResult = NO;
            // declare a string and set its value to testSet object value
            NSString *objStr = (NSString *)obj;
            //comparison instructions
            //compare "testSet" to a an object in "setOfHats". and execute instruction based on results 
            if ([objStr hasPrefix:@"Orange"]) {
                testResult = YES;
            if ([objStr hasSuffix:@"Tie"]) {
                testResult = YES;
            return testResult;
        // "testSet" elavaluates "setOfHats" by comparing the (id)"objStr" 
        // print testSet
        NSLog(@"\n\n The Set Objects Are: %@",testSet);

The Set Objects Are: {(

Any criticism is welcome, thanks