zoukankan      html  css  js  c++  java
  • NSValue包装自定义结构体

    typedef struct {
        int year;
        int month;
        int day;        
    }Date;
    
    void value(){
        Date date = {2013,9,30},
        //void *代表任何类型的指针
        //这里要穿结构图的地址&date
        //根据结构体类型生成对应的描述字符串
        char* type = @encode(Date);
        
        NSValue *value=[NSValue value:&date withObjCType :type];  
      
          //定义结构体变量
          Date date1;
          //取出包装好的结构体
          [value getValue:&date1];
          NSLog(@"year=%i,month=%i,day = %i",date1.year,date1.month,date1.day);
         
    }
  • 相关阅读:
    python10.31
    python10.29
    python10.28
    python10.27
    python10.25
    python10.24
    python10.23
    四边形不等式与决策单调
    0x57~0x59
    0x55~0x56
  • 原文地址:https://www.cnblogs.com/yyh123/p/3346960.html
Copyright © 2011-2022 走看看