iOS 根据生日计算生肖

-(void)testStr:(NSString *)str{
    NSArray *array=@[@"鼠_4",@"牛_5",@"虎_6",@"兔_7",@"龙_8",@"蛇_9",@"马_10",@"羊_11",@"猴_0",@"鸡_1",@"狗_2",@"猪_3"];
    for (int i=0; i<array.count; i++) {
        if ([[array[i] componentsSeparatedByString:@"_"][1] isEqualToString:[NSString stringWithFormat:@"%ld",[str integerValue]%12]]) {
            NSLog(@"属%@",[array[i] componentsSeparatedByString:@"_"][0]);
        }
    }
}

 

posted @ 2016-03-02 22:05  筱筱心意  阅读(660)  评论(0编辑  收藏  举报