怎么创建一个nscalendar

哪位知道,怎么创建一个nscalendar
最新回答
纯洁的小黄瓜

2024-09-29 01:58:39

使用currentCalendar函数就可以了。例如:
NSCalendar * myCal = [NSCalendar current Calendar];

下面是苹果官网的说明:

System Locale Information

+ currentCalendar

Returns the logical calendar for the current user.

Declaration

Swift

class func currentCalendar() -> NSCalendar

Objective-C

+ (NSCalendar *)currentCalendar

Return Value

The logical calendar for the current user.

Discussion

The returned calendar is formed from the settings for the current
user’s chosen system locale overlaid with any custom settings the user
has specified in System Preferences. Settings you get from this calendar
do not change as System Preferences are changed, so that your
operations are consistent (contrast with autoupdatingCurrentCalendar).

参考:
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/#//apple_ref/occ/clm/NSCalendar/currentCalendar