zoukankan      html  css  js  c++  java
  • 一来一回,

    4.4、通过NSCALENDAR类来创建日期 

            NSDateComponents *comp = [[NSDateComponents alloc]init]; 

            [comp setMonth:06]; 

            [comp setDay:01]; 

            [comp setYear:2001]; 

            NSCalendar *myCal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 

            NSDate *myDate1 = [myCal dateFromComponents:comp]; 

            NSLog(@"myDate1 = %@",myDate1); 

     

    4.5、从已有日期获取日期 

            unsigned units  = NSMonthCalendarUnit|NSDayCalendarUnit|NSYearCalendarUnit; 

            NSDateComponents *comp1 = [myCal components:units fromDate:now]; 

            NSInteger month = [comp1 month]; 

            NSInteger year = [comp1 year]; 

            NSInteger day = [comp1 day]; 

  • 相关阅读:
    IOS之UIKit_Day13
    IOS之UIKit_Day12
    IOS之UIKit_Day11
    IOS之UIKit_Day10
    iOS设计模式之工厂模式
    常用操作
    盒子模式
    block循环使用问题
    IOS-sqlite3
    IOS-View用作控制器
  • 原文地址:https://www.cnblogs.com/guligei/p/3196018.html
Copyright © 2011-2022 走看看