1 #import <Foundation/Foundation.h>
2
3 @interface NSString (print)
4 -(void)print;
5 -(void)show:(NSString *)str;
6 @end
7
8 @implementation NSString(print)
9 -(void)print{
10 NSLog(@"%@",self);
11 }
12 -(void)show:(NSString *)str{
13 NSLog(@"%@ : %@",str,self);
14 }
15 @end
16
17 int main(int argc,char **argv){
18 @autoreleasepool {
19 NSMutableSet *mset = [NSMutableSet setWithObjects:@"zhangsan",@"lisi",@"wangwu", nil];
20
21 [mset addObject:@"zhaoliu"];
22 NSLog(@"mset = %@",mset);
23
24 [mset addObjectsFromArray:@[@"111",@"222",@"333"]];
25 NSLog(@"mset = %@",mset);
26
27 [mset removeObject:@"111"];
28 NSLog(@"mset = %@",mset);
29
30 NSSortDescriptor *sortdesr = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES];
31 NSArray *sortset = [mset sortedArrayUsingDescriptors:@[sortdesr]];
32 NSLog(@"mset sort = %@",sortset);
33
34 NSArray *array = [mset allObjects];
35 NSLog(@"array = %@",array);
36 NSSet *set2 = [NSSet setWithArray:array];
37 NSLog(@"set2 = %@",set2);
38
39 NSString *str = [mset anyObject];
40 NSLog(@"str = %@",str);
41
42 [mset setSet:set2];
43 NSLog(@"mset = %@",mset);
44
45 [mset removeAllObjects];
46 NSLog(@"mset = %@",mset);
47 }
48 }