1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
NSSet *set1 = [NSSet setWithObjects:@"1",@"2", nil]; NSSet *set2 = [NSSet setWithObjects:@"3",@"4",@"5",@"6", nil]; NSArray *array = [NSArray arrayWithObjects:@"6",@"7",@"8", nil]; NSSet *set3 = [NSSet setWithArray:array]; NSSet *set4 = [NSSet setWithSet:set1]; NSSet *set5 = [NSSet setWithObjects:@"1",@"2", nil]; NSSet *set6 = [NSSet setWithObjects:@"1",@"2",@"6",@"7", nil];
NSLog(@"set1 = %@",set1); NSLog(@"set2 = %@",set2); NSLog(@"set3 = %@",set3); NSLog(@"set4 = %@",set4);
NSInteger count = [set3 count]; NSLog(@"set3 count = %ld",(long)count);
NSString *string = [set3 anyObject]; NSLog(@"string = %@",string);
NSArray *objects = [set3 allObjects]; NSLog(@"objects = %@",objects);
BOOL isContain = [set3 containsObject:@"6"]; BOOL isContain1 = [set3 containsObject:@"10"]; NSLog(@"isContain = %d, isContain1 = %d",isContain, isContain1);
BOOL isIntersect = [set2 intersectsSet:set3]; BOOL isInterset1 = [set1 intersectsSet:set2]; NSLog(@"isItersect = %ld,isItersect1 = %ld",(long)isIntersect,(long)isInterset1);
BOOL isEqual = [set1 isEqualToSet:set2]; BOOL isEqual1 = [set1 isEqualToSet:set5]; NSLog(@"isEqual = %ld,isEqual1 = %ld",(long)isEqual,(long)isEqual1);
BOOL isSub = [set2 isSubsetOfSet:set3]; bool isSub1 = [set1 isSubsetOfSet:set6]; NSLog(@"isSub = %ld, isSub1 = %ld",(long)isSub, (long)isSub1);
NSSet *set7 = [set5 setByAddingObject:@"One"]; NSLog(@"set7 = %@",set7); NSArray *array1 = [NSArray arrayWithObjects:@"two",@"three",@"four", nil]; NSSet *set8 = [set7 setByAddingObjectsFromArray:array1]; NSLog(@"set8 = %@",set8); NSSet *set9 = [set8 setByAddingObjectsFromSet:set5]; NSLog(@"set9 = %@",set9);
NSMutableSet *mutableSet1 = [NSMutableSet set]; NSMutableSet *mutableSet2 = [NSMutableSet setWithObjects:@"1",@"a", nil]; NSMutableSet *mutableSet3 = [NSMutableSet setWithObjects:@"2",@"a", nil]; NSMutableSet *mutableSet4 = [NSMutableSet setWithObjects:@"2",@"a",@"b", nil]; NSMutableSet *mutableSet5 = [NSMutableSet setWithObjects:@"2",@"a",@"b",@"c",@"d", nil]; NSLog(@"mutableSet1 = %@",mutableSet1); NSLog(@"mutableSet2 = %@",mutableSet2); NSLog(@"mutableSet3 = %@",mutableSet3);
[mutableSet1 setSet:mutableSet3]; NSLog(@"mutableSet1 = %@",mutableSet1);
NSLog(@"mutableSet4 = %@",mutableSet4); [mutableSet4 removeObject:@"b"]; NSLog(@"mutableSet4 = %@",mutableSet4); [mutableSet4 removeAllObjects]; NSLog(@"mutableSet4 = %@",mutableSet4);
NSLog(@"mutableSet5 = %@",mutableSet5); NSArray *array2 = [NSArray arrayWithObjects:@"e",@"f", nil]; [mutableSet5 addObjectsFromArray:array2]; NSLog(@"mutableSet5 = %@",mutableSet5);
|