Skip to content

Instantly share code, notes, and snippets.

@b-adams
Created July 11, 2012 03:13
Show Gist options
  • Save b-adams/3087753 to your computer and use it in GitHub Desktop.
Save b-adams/3087753 to your computer and use it in GitHub Desktop.
Objective-C test snippets
// unionSet respects counted set counts
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
NSCountedSet* cSet = [NSCountedSet set];
[cSet addObject:@"Yo"];
id obj = @"Ho";
[cSet addObject:obj];
[cSet addObject:obj];
[cSet addObject:@"Bottle of Rum"];
NSLog(@"Pre-union %@", cSet);
NSSet* set = [NSSet setWithObjects:@"Hi", @"Hi", obj, @"Hum", nil];
[cSet unionSet:set];
NSLog(@"Post-union %@", cSet);
[cSet unionSet:cSet];
NSLog(@"Post self-union: %@", cSet);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment