本帖最后由 ios_xiaot 于 2015-7-2 22:35 编辑
- //常用的方法纪录下
- //以@方法创建
- __unused NSDictionary * dic3 = @{@"firstname":@"Mark",@"secondname":@"Toot",@"age":@30,@"sex":@"Male"};
- NSNumber *numObj = [NSNumber numberWithInt:100];
- //以一个元素初始化
- __unused NSDictionary *dic0 = [NSDictionary dictionaryWithObject:numObj forKey:@"key"];
- //初始化两个元素
- NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:numObj, @"valueKey", @"1234567", @"value2",nil];
- //初始化新字典,新字典包含otherDic
- __unused NSDictionary *dic2 = [NSDictionary dictionaryWithDictionary:dic1];
- //通过枚举类型枚举字典
- NSEnumerator *enumerator = [dic1 keyEnumerator];
- id key = [enumerator nextObject];
- while (key) {
- id obj = [dic1 objectForKey:key];
- NSLog(@"%@", obj);
- key = [enumerator nextObject];
- }
复制代码
|
|