zoukankan      html  css  js  c++  java
  • ios 学习笔记 3

            NSLog(@"Hello, World!");
    NSDictionary *myDic=[[NSDictionary alloc]initWithObjectsAndKeys:@"张三",@"name",@"李四",@"name", nil];

    NSUInteger count = [myDic count];
    NSLog(@"词典的数量为: %lu",count);

    NSEnumerator * myEnumerator = [myDic keyEnumerator];


    for (NSObject *object in myEnumerator) {
    NSLog(@"遍历KEY的值: %@",object);
    }

    myEnumerator = [[myDic allValues] objectEnumerator];
    NSString *value;
    while((value = [myEnumerator nextObject]))
    {
    NSLog(@"遍历的值: %@",value);
    }

    //通过KEY找到value
    NSObject *myObject = [myDic objectForKey:@"name"];

    if (myObject != nil) {
    NSLog(@"通过KEY找到的value是: %@",myObject);
    }

    NSMutableDictionary *mydic2 = [NSMutableDictionary dictionaryWithCapacity:10];
    [mydic2 setObject:@"Alex Hu" forKey:@"name"];
    [mydic2 setObject:@"1388888888" forKey:@"mobile number"];

    for (NSObject *object in [mydic2 objectEnumerator]) {
    NSLog(@"遍历的值: %@",object);
    }

    NSSet *mySet=[NSSet setWithObjects:@"A",@"B",@"C",@"D",[NSNumber numberWithInteger:123], nil];
    count=[mySet count];
    NSLog(@"count= %lu",count);

    myEnumerator=[mySet objectEnumerator];
    for (NSObject *object in myEnumerator) {
    NSLog(@"myEnumerator value=%@",object);
    if ([object isEqualTo:@"A"]) {
    NSLog(@"找到A了");
    }
    if ([object isEqual:@"B"]) {
    NSLog(@"找到B");
    }
    }

    NSArray *mySetArr=[mySet allObjects];
    for (NSUInteger i=0; i<[mySetArr count];i++) {
    NSLog(@"%lu =>%@",i,[mySetArr objectAtIndex:i]);
    }

    if ([mySet containsObject:@"D"]) {
    NSLog(@"集合中包含 D这个对象");
    }
  • 相关阅读:
    MySQL(数据库)
    移动端兼容
    Vue常用指令
    JS浮点运算精度问题
    ES11新增的9个新特性
    后端要采用ArrayBuffer上传文件
    重磅来袭 Vue 3.0 One Piece 正式发布
    Vue 事件的高级使用方法
    浏览器的回流与重绘(Reflow&Repaint)
    微前端介绍
  • 原文地址:https://www.cnblogs.com/hubj/p/2327442.html
Copyright © 2011-2022 走看看