iOS Developer Library

Developer

EventKit Framework Reference EKCalendar Class Reference

Options
Deployment Target:

On This Page
Language:

EKCalendar

An instance of the EKCalendar class represents a calendar in Event Kit. Use the properties in this class to get attributes about a calendar, such as its title and type. Use the calendarForEntityType:eventStore: method to create a calendar object.

  • Creates and returns a calendar belonging to a specified event store.

    Declaration

    Objective-C

    + (EKCalendar *)calendarWithEventStore:(EKEventStore *)eventStore

    Parameters

    eventStore

    The event store to which the event belongs.

    Return Value

    The created calendar.

    Availability

    Available in iOS 4.0 and later.

    Deprecated in iOS 6.0.

  • Creates a new calendar that can contain the given entity type.

    Declaration

    Swift

    init(forEntityType entityType: EKEntityType, eventStore eventStore: EKEventStore)

    Objective-C

    + (EKCalendar *)calendarForEntityType:(EKEntityType)entityType eventStore:(EKEventStore *)eventStore

    Parameters

    entityType

    The entity type that this calendar may support.

    eventStore

    The event store in which to create this calendar.

    Return Value

    The created calendar.

    Discussion

    You can only create calendars that accept either reminders or events. Some servers might allow mixing the two, although it is not common.

    Availability

    Available in iOS 6.0 and later.

  • A Boolean value that indicates whether you can add, edit, and delete items in the calendar. (read-only)

    Declaration

    Swift

    var allowsContentModifications: Bool { get }

    Objective-C

    @property(nonatomic, readonly) BOOL allowsContentModifications

    Availability

    Available in iOS 4.0 and later.

  • The calendar’s color.

    Declaration

    Swift

    var CGColor: CGColor

    Objective-C

    @property(nonatomic) CGColorRef CGColor

    Special Considerations

    This property is the equivalent of the color property on OS X.

    Availability

    Available in iOS 4.0 and later.

  • A Boolean value indicating whether the calendar’s properties can be edited or deleted. (read-only)

    Declaration

    Swift

    var immutable: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isImmutable) BOOL immutable

    Discussion

    If YEStrue, the calendar is immutable; otherwise it is not. Events and reminders can still be added to an immutable calendar.

    Availability

    Available in iOS 5.0 and later.

  • The calendar’s title.

    Declaration

    Swift

    var title: String

    Objective-C

    @property(nonatomic, copy) NSString *title

    Availability

    Available in iOS 4.0 and later.

  • type type Property

    The calendar’s type. (read-only)

    Declaration

    Swift

    var type: EKCalendarType { get }

    Objective-C

    @property(nonatomic, readonly) EKCalendarType type

    Discussion

    CalDAV-subscribed calendars are of type EKCalendarTypeCalDAV with isSubscribed set to YEStrue.

    Availability

    Available in iOS 4.0 and later.

    See Also

    EKCalendarType

  • The entity types this calendar can contain. (read-only)

    Declaration

    Swift

    var allowedEntityTypes: EKEntityMask { get }

    Objective-C

    @property(nonatomic, readonly) EKEntityMask allowedEntityTypes

    Discussion

    While Event Kit only allows creation of single-entity calendars, other servers might allow mixed-entity calendars.

    Availability

    Available in iOS 6.0 and later.

  • The source object representing the account to which this calendar belongs.

    Declaration

    Swift

    var source: EKSource

    Objective-C

    @property(nonatomic, strong) EKSource *source

    Discussion

    This property can only be set for newly created calendar objects. This property is read-only after the first time it is set; setting a value to this property after the first time it is set will result in an error. Therefore, moving a calendar from one source to another is not supported.

    Availability

    Available in iOS 5.0 and later.

  • A Boolean value indicating whether the calendar is a subscribed calendar. (read-only)

    Declaration

    Swift

    var subscribed: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isSubscribed) BOOL subscribed

    Discussion

    If YEStrue, the calendar is a subscribed calendar; otherwise it is not.

    Availability

    Available in iOS 5.0 and later.

  • The event availability settings supported by this calendar, as indicated by a bitmask. (read-only)

    Declaration

    Swift

    var supportedEventAvailabilities: EKCalendarEventAvailabilityMask { get }

    Objective-C

    @property(nonatomic, readonly) EKCalendarEventAvailabilityMask supportedEventAvailabilities

    Discussion

    If the calendar doesn’t support event availability settings, this value is EKCalendarEventAvailabilityNone.

    Availability

    Available in iOS 4.0 and later.

  • A unique identifier for the calendar. (read-only)

    Declaration

    Swift

    var calendarIdentifier: String { get }

    Objective-C

    @property(nonatomic, readonly) NSString *calendarIdentifier

    Discussion

    This property is set when the calendar is created and can be used as a local identifier. Use calendarWithIdentifier: to get a calendar with the specified identifier.

    A full sync with the calendar will lose this identifier. You should have a plan for dealing with a calendar whose identifier is no longer fetch-able by caching its other properties.

    Availability

    Available in iOS 5.0 and later.

Data Types

  • Possible calendar types.

    Declaration

    Swift

    enum EKCalendarType : Int { case Local case CalDAV case Exchange case Subscription case Birthday }

    Objective-C

    typedef enum { EKCalendarTypeLocal, EKCalendarTypeCalDAV, EKCalendarTypeExchange, EKCalendarTypeSubscription, EKCalendarTypeBirthday, } EKCalendarType;

    Constants

    • Local

      EKCalendarTypeLocal

      A local calendar.

      Available in iOS 4.0 and later.

    • CalDAV

      EKCalendarTypeCalDAV

      A CalDAV or iCloud calendar.

      Available in iOS 4.0 and later.

    • Exchange

      EKCalendarTypeExchange

      An Exchange calendar.

      Available in iOS 4.0 and later.

    • Subscription

      EKCalendarTypeSubscription

      A locally subscribed calendar.

      Available in iOS 4.0 and later.

    • Birthday

      EKCalendarTypeBirthday

      A birthday calendar.

      Available in iOS 4.0 and later.

    Import Statement

    Objective-C

    @import EventKit;

    Swift

    import EventKit

    Availability

    Available in iOS 4.0 and later.

  • A bitmask indicating the event availability settings that the calendar can support.

    Declaration

    Swift

    struct EKCalendarEventAvailabilityMask : OptionSetType { init(rawValue rawValue: UInt) static var None: EKCalendarEventAvailabilityMask { get } static var Busy: EKCalendarEventAvailabilityMask { get } static var Free: EKCalendarEventAvailabilityMask { get } static var Tentative: EKCalendarEventAvailabilityMask { get } static var Unavailable: EKCalendarEventAvailabilityMask { get } }

    Objective-C

    typedef NSUInteger EKCalendarEventAvailabilityMask;

    Import Statement

    Objective-C

    @import EventKit;

    Swift

    import EventKit

    Availability

    Available in iOS 4.0 and later.

  • Event availability settings that the calendar can support.

    Declaration

    Swift

    struct EKCalendarEventAvailabilityMask : OptionSetType { init(rawValue rawValue: UInt) static var None: EKCalendarEventAvailabilityMask { get } static var Busy: EKCalendarEventAvailabilityMask { get } static var Free: EKCalendarEventAvailabilityMask { get } static var Tentative: EKCalendarEventAvailabilityMask { get } static var Unavailable: EKCalendarEventAvailabilityMask { get } }

    Objective-C

    enum { EKCalendarEventAvailabilityNone = 0, EKCalendarEventAvailabilityBusy = (1 << 0), EKCalendarEventAvailabilityFree = (1 << 1), EKCalendarEventAvailabilityTentative = (1 << 2), EKCalendarEventAvailabilityUnavailable = (1 << 3), };

    Constants

    • None

      EKCalendarEventAvailabilityNone

      The calendar does not support event availability settings.

      Available in iOS 4.0 and later.

    • Busy

      EKCalendarEventAvailabilityBusy

      The calendar supports the busy event availability setting.

      Available in iOS 4.0 and later.

    • Free

      EKCalendarEventAvailabilityFree

      The calendar supports the free event availability setting.

      Available in iOS 4.0 and later.

    • Tentative

      EKCalendarEventAvailabilityTentative

      The calendar supports the tentative event availability setting.

      Available in iOS 4.0 and later.

    • Unavailable

      EKCalendarEventAvailabilityUnavailable

      The calendar supports the unavailable event availability setting.

      Available in iOS 4.0 and later.