objc++.mm 607 B

1234567891011121314151617181920212223
  1. #import <Cocoa/Cocoa.h>
  2. #import <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  7. NSMutableSet *mySet = [NSMutableSet set];
  8. cout<<"Adding values to the set."<<endl;
  9. [mySet addObject:[NSNumber numberWithInt:356]];
  10. [mySet addObject:[NSNumber numberWithInt:550]];
  11. [mySet addObject:[NSNumber numberWithInt:914]];
  12. cout<<"The set contains "<<[mySet count]<<" objects."<<endl;
  13. if ([mySet containsObject:[NSNumber numberWithInt:911]])
  14. cout<<"It's there!"<<endl;
  15. else
  16. cout<<"It's not there."<<endl;
  17. [pool release];
  18. return 0;
  19. }