码迷,mamicode.com
首页 > 移动开发 > 详细

iOS中根据月和日获取星座名

时间:2015-03-12 15:09:13      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:ios   oc   星座   

技术分享


/**
 *  根据月和日的下标获取星座名
 *
 *  @param monthIndex 月的下标
 *  @param dayIndex   日的下标
 *
 *  @return 星座名
 */
- (NSString *)getConstellationNameByMonthIndex:(NSInteger)monthIndex dayIndex:(NSInteger)dayIndex {
    NSArray *constellations = @[@"水瓶座", @"双鱼座", @"白羊座", @"金牛座", @"双子座", @"巨蟹座", @"狮子座", @"处女座", @"天秤座", @"天蝎座", @"射手座", @"摩羯座"];
    NSInteger index;
    NSArray *conIndexs = @[@(20),@(19),@(21),@(20),@(21),@(22),@(23),@(23),@(23),@(24),@(23),@(22)];
    if ([[conIndexs objectAtIndex:monthIndex] integerValue] <= dayIndex + 1) {
        index = monthIndex;
    } else index = (monthIndex - 1 + 12) % 12;
    return [constellations objectAtIndex:index];
}





iOS中根据月和日获取星座名

标签:ios   oc   星座   

原文地址:http://blog.csdn.net/macro_13/article/details/44221321

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!