爱程序网

【代码笔记】获得当前的月的天数

来源: 阅读:

一,代码。

复制代码
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    NSLog(@"8月的天数%ld",(long)[self getCurrentDay:8]);
    
}
#pragma -mark -functions
//获得当前的月的天数
-(NSInteger )getCurrentDay:(int) currentMonth{
    if (currentMonth < 8 ) {
        if (currentMonth %2 ==1) {
            return 31;
        }else{
            return 30;
        }
    }else{
        if (currentMonth %2 ==1) {
            return 30;
        }else{
            return 31;
        }
    }
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
复制代码

 

二,输出。

2015-10-19 13:33:04.785 获得当前的月的天数[5116:115173] 8月的天数31

 

 

 
 

关于爱程序网 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助