SCKViewController
@objc open class SCKViewController: NSViewController
A NSViewController subclass that sets up a schedule view embedded in a scroll view and displays a set of events within a day or a week time interval. The SCKViewController implements all the event processing and conflict handling logic. It also manages the zooming and the day/week offsetting for you.
To provide events to a SCKViewController, just make an object or a subclass
conform to SCKEventManaging
or SCKConcreteEventManaging
and set the
eventManager
property. Finally, call a suitable reload data method to execute
the first event fetch.
If you use Swift, you may choose between implementing SCKEventManaging
or
working in concrete mode by conforming to SCKConcreteEventManaging
and
declaring an event type. Use the concrete mode when working with a single
event class to benefit from Swift’s type safety and work with better-typed
methods in your event manager implementation. If you do so, you must also use
the reloadData(ofConcreteType:)
method to begin new event fetches. If you
work with multiple event classes, you’ll have to use SCKEventManaging
and
call reloadData()
to load new events instead.
Events are fetched synchronously by default, but asynchronous event fetching
is also available by setting the loadsEventsAsynchronously
property to true
and implementing the proper event manager methods.
Note
SCKConcreteEventManaging
is not available in Objective-C. In
addition, the event manager must be set via -setObjCDelegate:
.
-
Set this attribute to control whether events must be displayed in a
SCKDayView
or in aSCKWeekView
. Ideally, set the appropiate value before the controller’s view is loaded, overridingloadView()
if necessary. You may also use this property to switch between modes once a schedule view is already installed.Declaration
Swift
@objc public var mode: SCKViewControllerMode = .day
-
The scroll view managed by the controller.
Declaration
Swift
@objc public private(set) var scrollView: NSScrollView =
-
The schedule view managed by the controller
Declaration
Swift
@objc public private(set) var scheduleView: SCKView!
-
Undocumented
Declaration
Swift
@objc open class SCKViewController: NSViewController
-
The object that works as the data source and delegate for this controller. A common implementation when subclassing
SCKViewController
is to make the subclass conform to eitherSCKEventManaging
orSCKConcreteEventManaging
and set itself as the event manager.Note
In an Objective-C target, you must use thedelegate
property instead.Declaration
Swift
public weak var eventManager: SCKEventManaging?
-
Triggers a synchronous or asynchronous event fetch operation on the event manager object. The used method will depend on the value of the
loadsEventsAsynchronously
property.Important
This is the method you should call to reload data from an Objective-C target or when working with multiple event classes, but never in the concrete type mode. See more about the available options in the class description. Once you’ve called this, you must always reload data using the same method (and notreloadData(ofConcreteType)
.Declaration
Swift
@objc public final func reloadData()
-
Triggers a synchronous or asynchronous event fetch operation on the event manager object. The used method will depend on the value of the
loadsEventsAsynchronously
property.Important
This is the method you should call to reload data when working with a single event class in Swift, but never when working with multiple event classes. See more about the available options in the class description. Once you’ve called this, you must always reload data using the same method (and not
reloadData()
.Parameter
Parameter ofConcreteType: The event class being used with this controller.
Declaration
Swift
public final func reloadData<T: SCKEvent>(ofConcreteType: T.Type)
Parameters
ofConcreteType
The event class being used with this controller.
-
Set this property to
true
to perform event fetching asyncronously. Default value isfalse
.Declaration
Swift
public var loadsEventsAsynchronously: Bool = false
-
Displays the previous day or week and performs a new event fetch.
Parameter
Parameter sender: The UI control that initiated the action.Declaration
Swift
@IBAction public func decreaseOffset(_ sender: AnyObject)
Parameters
sender
The UI control that initiated the action.
-
Displays the next day or week and performs a new event fetch.
Parameter
Parameter sender: The UI control that initiated the action.Declaration
Swift
@IBAction public func increaseOffset(_ sender: AnyObject)
Parameters
sender
The UI control that initiated the action.
-
Displays the default date interval (today or this week) and performs a new event fetch.
Parameter
Parameter sender: The UI control that initiated the action.Declaration
Swift
@IBAction public func resetOffset(_ sender: AnyObject)
Parameters
sender
The UI control that initiated the action.
-
Decreases the schedule view’s hour height.
Parameter
Parameter sender: The UI control that initiated the action.Declaration
Swift
@IBAction public func decreaseZoomFactor(_ sender: AnyObject)
Parameters
sender
The UI control that initiated the action.
-
Increases the schedule view’s hour height.
Parameter
Parameter sender: The UI control that initiated the action.Declaration
Swift
@IBAction public func increaseZoomFactor(_ sender: AnyObject)
Parameters
sender
The UI control that initiated the action.
-
The object that works as the data source and delegate for this controller. Use the
-setObjCDelegate:
method to set it.Note
In a Swift target, you must use theeventManager
property instead.Declaration
Swift
@objc public private(set) weak var delegate: SCKObjCEventManaging?
-
Stops observing title, user, duration and scheduledDate changes from a given object. After calling this method, the schedule view will not reflect any change in that event.
Parameter
Parameter event: The event that you don’t want to be observed.Declaration
Swift
@objc public final func stopObservingChanges(from event: SCKEvent)
Parameters
event
The event that you don’t want to be observed.