ScheduleKit is a powerful graphical event management framework for macOS that provides a great way to display a set of event-like objects in either a day or week based timetable.
ScheduleKit is a powerful graphical event management framework for macOS that provides a great way to display a set of event-like objects in either a day or week based timetable.
ScheduleKit 2.0 has been completely rewritten and its workflow is way different in relation to the one present in previous releases. If you need source compatibility, please keep using the 1.0 release.
SCKViewController
class, which works like any other NSViewController, provides automatic event management with conflict handling. Just implement the SCKEventManaging
protocol to add a bunch of events!SCKViewController
supports asynchronously loading events by just changing the value of a property and implementing the appropiate method.In a swift target, you may choose between creating a SCKViewController
subclass or using the SCKViewController
class itself as a child view controller of another view controller of your own. Just choose the approach that feels more confortable to you.
SCKViewController
subclass. You can either use it programatically or add it to an Interface Builder storyboard or XIB file. You don’t have to insert any SCKView
instance nor any NSScrollView, that will be done automatically for you.loadView()
method to set your preference before the view is set up.viewWillAppear()
and:
reloadData()
if you are using multiple event classes or reloadData(ofConcreteType)
for an easier implementation if you’re using a single event class.SCKEventManaging
(or SCKConcreteEventManaging
) data source method to provide events to the view. The choice will depend on the reload data method you’re using in step 3.4. Check the documentation to learn more.override func loadView() {
mode = .week
super.loadView()
}
override func viewWillAppear() {
super.viewWillAppear()
self.eventManager = self
let calendar = Calendar.current
let start = calendar.date(from: calendar.dateComponents([.yearForWeekOfYear,.weekOfYear], from: Date()))!
let end = calendar.date(byAdding: .weekOfYear, value: 1, to: start)!
scheduleView.dateInterval = DateInterval(start: start, end: end)
scheduleView.delegate = self
reloadData(ofConcreteType: MyEventType.self)
}
let allEvents: [MyEventType] = [/* Some cool events */]
func concreteEvents(in dateInterval: DateInterval,
for controller: SCKViewController) -> [MyEventType] {
let filtered = allEvents.filter {$0.scheduledDate > dateInterval.start && $0.scheduledDate <= dateInterval.end}
return filtered
}
SCKViewController
instance as a child view controller of some other view controller. You can either do it programatically or add it to an Interface Builder storyboard or XIB file. If you do it in IB, be sure to add a blank NSView and configure it as its view, too.mode
property on the SCKViewController
from your own view controller before the SCKViewController’s view loads.viewWillAppear()
, do the following:
reloadData()
if you are using multiple event classes or reloadData(ofConcreteType)
for an easier implementation if you’re using a single event class.SCKEventManaging
(or SCKConcreteEventManaging
) data source method to provide events to the view. The choice will depend on the reload data method you’re using in step 3.4. Check the documentation to learn more.@IBOutlet weak var scheduleController: SCKViewController!
override func viewWillAppear() {
super.viewWillAppear()
scheduleController.eventManager = self
let calendar = Calendar.current
let start = calendar.date(from: calendar.dateComponents([.yearForWeekOfYear,.weekOfYear], from: Date()))!
let end = calendar.date(byAdding: .weekOfYear, value: 1, to: start)!
scheduleController.scheduleView.dateInterval = DateInterval(start: start, end: end)
scheduleController.scheduleView.delegate = self
scheduleController.reloadData()
}
let meetings: [Meeting] = [/* Some cool events */]
let otherEvents: [OtherEvent] = [/* Some cool events */]
func events(in dateInterval: DateInterval,
for controller: SCKViewController) -> [SCKEvent] {
let filteredMeetings = meetings.filter {$0.scheduledDate > dateInterval.start && $0.scheduledDate <= dateInterval.end}
let filteredOther = otherEvents.filter {$0.scheduledDate > dateInterval.start && $0.scheduledDate <= dateInterval.end}
return filteredMeetings + filteredOther
}
ScheduleKit is written Swift but you can use it in your Objective-C targets taking a few considerations into account:
SCKViewController
’s event manager using the eventManager
property. Please use the -setObjCDelegate:
method instead.SCKConcreteEventManaging
protocol uses Swift generics and is not available.
- (void)viewWillAppear {
[super viewWillAppear];
[_scheduleController setObjCDelegate:self];
[_scheduleController.scheduleView setDelegate:self];
[self addChildViewController:_scheduleController];
NSCalendar *cal = [NSCalendar currentCalendar];
NSDate *today = [NSDate date];
NSDate *dayStart = [cal dateBySettingHour:0 minute:0 second:0 ofDate:today options:0];
NSDate *dayEnd = [cal dateBySettingHour:23 minute:59 second:59 ofDate:today options:0];
NSDateInterval *interval = [[NSDateInterval alloc] initWithStartDate:dayStart endDate:dayEnd];
[_scheduleController.scheduleView setDateInterval:interval];
[_scheduleController reloadData];
}
@property (strong) IBOutlet SCKViewController * scheduleController;
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate ScheduleKit into your Xcode project using Carthage, specify it in your cartfile
:
github "gservera/ScheduleKit" "master"
Run carthage update
on your project’s directory to build the framework and drag the built ScheduleKit.framework
into your Xcode project.
ScheduleKit includes a suite of unit tests within the ScheduleKitTests subdirectory. These tests can be run simply be executed the test action on the platform framework you would like to test.
Guillem Servera, https://gservera.com
ScheduleKit is released under the MIT license. See LICENSE for details.