在x-code下的foundation的各种使用

来源:互联网 发布:注册域名免费 编辑:程序博客网 时间:2024/05/16 10:08
#import

int main(int argc, const char * argv[])
{
    @autoreleasepool {
       
      //-------------------NSNumber------------------
      
       
      //------------------------NSString-------------------
      
       
       
      //--------------------------------NSArray---------------------------
      
       
       
       
      //--------------------------------NSDictionary-----------------------
       //----- 初始化
      
       
      //----------------------------------NSSet-------------------
       //----- 定义、初始化
       NSSet *set = [[NSSet alloc]initWithObjects:@"one",@"one",@"two",nil];
       
       //用数组定义NSSet;
       NSArray *arrayset = [NSArrayarrayWithObjects:@"1",@"2",@"3",nil];
       
       NSSet *set2 = [NSSetsetWithArray:arrayset];
       
       NSLog(@"set1 = %@,set2 = %@",set,set2);
       //访问方式
       //----- 获取长度
       int len = [set2 count];
       
       NSString *s = [set2 anyObject];
       
       NSLog(@"set2 length = %d,obj = %@",len,s);
       
    }
    return 0;
}

原创粉丝点击