标签:style with js for init object har nil add 信息
main
#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { NSDictionary* dic =[NSDictionary dictionaryWithObject:@1 forKey:@"1"]; NSDictionary* dic2=@{@"1":@1,@"2":@2}; NSDictionary* dic3=[NSDictionary dictionaryWithObjectsAndKeys:@1,@"1",@2,@"2", nil]; NSArray* objs=@[@1,@2]; NSArray* keys=@[@"1",@"2"]; NSDictionary* dic4 =[NSDictionary dictionaryWithObject:objs forKey:keys]; //字典对象的使用 id obj =[dic2 objectForKey:@"2"]; NSLog(@"%@",obj); for(id key in dic3) { id obj =[dic2 objectForKey:key]; NSLog(@"%@",obj); } // 用法 联系人的信息 NSDictionary* contact = @{@"name":@"Tom",@"age":@25,@"tel":@"15645530792",@"email":@"786577908@qq.com"}; NSDictionary* contact2 = @{@"name":@"Tom2",@"age":@35,@"tel":@"156455307923",@"email":@"786577908@qq.com"}; NSMutableArray* contractbook=[[NSMutableArray alloc] init]; [contractbook addObject:contact]; [contractbook addObject:contact2]; // 并不是按照顺序 也是hash table NSLog(@"%@",contractbook); } return 0; }
OC基础 Foundation基础 NSDictionary
标签:style with js for init object har nil add 信息
原文地址:https://www.cnblogs.com/zhangqing979797/p/13276953.html