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这个对象");
    }
  • 相关阅读:
    微信小程序分享及信息追踪
    vue刷新路由,不刷新页面
    vue中是使用富文本编辑器vue-quill-edit
    下载配置nodeJs,cnpm,webpack,vue-cli等,刚装的系统,所有东西重新配置
    promise学习总结
    【转】前端的BFC、IFC、GFC和FFC
    ES6中export与export default的区别
    前端常见跨域解决方案
    vue2.0s中eventBus实现兄弟组件通信
    RHEL5 yum更新源
  • 原文地址:https://www.cnblogs.com/hubj/p/2327442.html
Copyright © 2011-2022 走看看