呆呆陈

博客园 首页 新随笔 联系 订阅 管理

 

第一种:

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;

}

posted on 2016-12-23 09:47  我是一只萌妹子  阅读(178)  评论(0编辑  收藏  举报