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;

    }

  • 相关阅读:
    Oracle分页查询
    Oracle表空间
    Oracle中DBA常用操作
    数据库的约束
    数据库设计的三范式
    数据类型的比较 有四种情况
    github快速上手
    3D正方体做法
    animation-声明关键帧
    轮播图样式
  • 原文地址:https://www.cnblogs.com/chenzq12/p/6213676.html
Copyright © 2011-2022 走看看