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

以下是创建字典的方法。 

 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);

 

 

相关文章:

  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2021-09-14
猜你喜欢
  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
相关资源
相似解决方案