NSSet* set = [NSSetset];//创建一个空的set不能往里面加东西了
NSSet* set1 = [NSSetsetWithObject:@"1"];
NSSet* set2 = [NSSetsetWithObjects:@"1",@"2",nil];
//NSSet是没有顺序的所以用set[0]是不可以的,只能用[set anyObject]取出任意值
//NSSet没有快速创建,没有快速访问
NSString* s = [set anyObject];
NSMutableSet* mset = [NSMutableSetset];//一个空的set但是可以往里面加东西
[mset addObject:@"1"];
[mset removeObject:@"1"];
//////////////////////////////
NSDictionary* dic1 = [NSDictionary dictionaryWithObject:@"jack" forKey:@"name"];
NSArray* objects = @[@"jack1",@"jack2"];
NSArray* keys = @[@"name1",@"name2"];
NSDictionary* dic2 = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
NSDictionary* dic3 = [NSDictionary dictionaryWithObjectsAndKeys:@"jack1",@"name1",@"jack2",@"name2", nil];
//快速创建,注意这个是键值对 前面是Key 后面是Value,注意顺序
NSDictionary* dic4 = @{@"name1":@"jack1",
@"name2":@"jack2"};
//获得Value的两种方式],快速访问
NSLog(@"%@",[dic4 objectForKey:@"name1"]);
NSLog(@"%@",dic4[@"name2"]);
//集合类中不能放基本数据类型(int,float,enum,struct)所以要把这些类型封装成OC对象才行
NSNumber* number = [NSNumber numberWithInt:10];
//取出NSNumber的基本数据
int n = [number intValue];//10
//NSNumber的快速创建
//@YES,@'A'
NSNumber* num = @20;
int age = 10;
NSNumber* _age = @(age);//不是@age,编译器会把@age当成关键字(比如@interface)
NSNumber *_ch = @'A';//NSNumber对象
NSString* _s = @"A";//NSString对象
//把OC字符串改成int
NSString* s = [NSString stringWithFormat:@"%d",10];
int _n = [s intValue];//10
//NSNumber只能封装数字但是不能封装结构体,NSValue可以封装结构体
CGPoint p = CGPointMake(10, 10);
NSValue* value = [NSValue valueWithPoint:p];
CGPoint _p = [value pointValue];