objective - c 字典

存储数据时,可以使用字典来存储,这样可以提高搜索速度。

以下是创建字典的方法。 

 NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:

  @"wtq",@"name1",

  @"wtm",@"name2",

  @"wtp",@"name3",

nil];


将字典的值输出来。 

NSLog(@"new dictionary is %@",[dic objectForKey:@"name2"]);

 

如何遍历字典;使用枚举。

NSEnumerator *e = [mtDic objectEnumerator];

id ee;

while (ee=[e nextObject]) {

NSLog(@" enumer %@",ee);

 

 

posted on 2011-10-05 18:48  wtq  阅读(295)  评论(0编辑  收藏  举报