zoukankan      html  css  js  c++  java
  • 根据数字对应星期几

    第一种:

    NSString *week  = @“2”

    NSString *Weekday =  [self passWeek:week];

     

    + (NSString *)passWeek:(NSString *)week {

        if ([week containsString:@"1"]) {

            week = [week stringByReplacingOccurrencesOfString: @"1" withString:@"周一"];

        }    else if ([week containsString:@"2"]) {

            week = [week stringByReplacingOccurrencesOfString:@"2" withString:@"周二"];

        }  else  if ([week containsString:@"3"]) {

            week = [week stringByReplacingOccurrencesOfString:@"3" withString:@"周三"];

        }   else  if ([week containsString:@"4"]) {

            week = [week stringByReplacingOccurrencesOfString:@"4" withString:@"周四"];

        }  else if ([week containsString:@"5"]) {

            week = [week stringByReplacingOccurrencesOfString:@"5" withString:@"周五"];

        }   else  if ([week containsString:@"6"]) {

            week = [week stringByReplacingOccurrencesOfString:@"6" withString:@"周六"];

        }   else if ([week containsString:@"7"]) {

            week = [week stringByReplacingOccurrencesOfString:@"7" withString:@"周日"];

        }

        return week;

    }

     

    第二种:

    NSString *week  = @“2,3,4”

    NSString *Weekday =  [self passWeek:week];

     

    + (NSString *)passWeek:(NSString *)week {

        if ([week containsString:@"1"]) {

            week = [week stringByReplacingOccurrencesOfString: @"1" withString:@"周一"];

        }  

       if ([week containsString:@"2"]) {

            week = [week stringByReplacingOccurrencesOfString:@"2" withString:@"周二"];

        }

       if ([week containsString:@"3"]) {

            week = [week stringByReplacingOccurrencesOfString:@"3" withString:@"周三"];

        }  

       if ([week containsString:@"4"]) {

            week = [week stringByReplacingOccurrencesOfString:@"4" withString:@"周四"];

        }

       if ([week containsString:@"5"]) {

            week = [week stringByReplacingOccurrencesOfString:@"5" withString:@"周五"];

        }  

        if ([week containsString:@"6"]) {

            week = [week stringByReplacingOccurrencesOfString:@"6" withString:@"周六"];

        }  

        if ([week containsString:@"7"]) {

            week = [week stringByReplacingOccurrencesOfString:@"7" withString:@"周日"];

        }

        return week;

    }

  • 相关阅读:
    [BZOJ]1040: [ZJOI2008]骑士
    [BZOJ]1177: [Apio2009]Oil
    【luogu3384】【模板】树链剖分
    【NOIP2012TG】solution
    【NOIP2014TG】solution
    【NOIP2016TG】solution
    【NOIP2015TG】solution
    【NOIP2016】【LCA】【树上差分】【史诗级难度】天天爱跑步
    【网络流】【BZOJ1221】【HNOI2001】软件开发
    【网络流】【BZOJ1061】【NOI2008】志愿者招募
  • 原文地址:https://www.cnblogs.com/chenzq12/p/6213676.html
Copyright © 2011-2022 走看看