NSCalendar - 在全球范围内设置自己的第一周

时间:2017-04-27 10:44:44

标签: ios objective-c nscalendar

是否有可能首先设定自定义周刊? 我应该继承NSCalendar?

现在我必须在我需要使用NSCalendar

的每个地方都这样设置
col_with_nulls = df.agg(*[(1 - (fn.count(c) / fn.count('*'))) 
                    for c in cols_to_categorise]).rdd

1 个答案:

答案 0 :(得分:1)

您可以使用惰性实例化变量编写NSCalendar类别:

@interface NSCalendar (WeekdayCalendar)

+ (NSCalendar *)customWeekdayCalendar;

@end

@implementation NSCalendar (WeekdayCalendar)

+ (NSCalendar *)customWeekdayCalendar
{
    static NSCalendar *customCalendar = nil;
    if (customCalendar == nil) {
        customCalendar = [self currentCalendar];
        customCalendar.firstWeekday = [NSUserDefaultsHelper firstDayOfWeek];
    }
    return customCalendar;
}

@end

然后你可以使用来自世界各地的日历

NSCalendar *myCalendar = [NSCalendar customWeekdayCalendar];