获取某个年份的生肖

学ios还很短,现在也在开发一些项目,之前一直是看别人的博客,然后学到了很多的东西,也少走了很多的弯路。现在自己也写了一些及其简单的东西,一是为了以后自己写项目的时候,能随时取。二是节省大家自己去写的时间,简单也得花点时间不是。
//计算生肖/传过来的值必须@“1978—————–”
//返回的是生肖@“猴”@“鸡”等…..
+(NSString*)getShengxiao:(NSString*)year{

NSString* one = [year substringWithRange:NSMakeRange(0, 4)];
int a = [one intValue];
NSString *shengxiao;
if (a % 12 == 0) {
    shengxiao = @"猴";
}
else if (a % 12 == 1){
    shengxiao = @"鸡";
}
else if (a % 12 == 2){
    shengxiao = @"狗";
}
else if (a % 12 == 3){
    shengxiao = @"猪";
}
else if (a % 12 == 4){
    shengxiao = @"鼠";
}
else if (a % 12 == 5){
    shengxiao = @"牛";
}
else if (a % 12 == 6){
    shengxiao = @"虎";
}
else if (a % 12 == 7){
    shengxiao = @"兔";
}
else if (a % 12 == 8){
    shengxiao = @"龙";
}
else if (a % 12 == 9){
    shengxiao = @"蛇";
}
else if (a % 12 == 10){
    shengxiao = @"马";
}
else if (a % 12 == 11){
    shengxiao = @"羊";
}
NSLog(@"%d年生肖是————————————%@年",a,shengxiao);
return shengxiao;

}

也就是这些了,希望大家在能用到的时候,能够减少大家些许的计算时间。以后也会持续发一些小东西。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值