David Sinclair, owner and developer of Dejal, has released the following Cocoa/Objective-C code as open source for macOS and iOS.
You are welcome to download and use this code, subject to the License Agreement. Read on for more information.
Note: most work nowadays is done in Swift; some of this code will be open-sourced at a later date.
Looking for a developer for your macOS or iOS project? David may be able to help. With more than a quarter century of commercial Mac programming experience, and nearly a decade on iOS, he brings a rich set of skills to any project. David is willing to consider long- or short-term projects, on an hourly, milestone, or per-job basis, working from his home office near Portland, Oregon. Learn more on the Consulting page.
The Dejal open source code is released under a standard BSD license.
Before downloading any of this code, please read the Dejal Open Source License page for details of attribution and more.
If you want or need to use the code without giving Dejal credit, non-attribution licenses are available for purchase from the Developer Store.
You can use this code completely free of charge, if you give Dejal credit. But if this code helps you solve a problem or saves you time, David always appreciates a donation to support and encourage future open source development.
Visit the Developer Store to make a donation via PayPal.
Alternatively, a fun option is to send David a gift from his Amazon.com Wish List. It's always nice to receive a surprise package in the mail.
If you use this code, David wants to hear from you! In the future we might link to apps that use these projects, which would help your Google juice. David can't promise to help with the code, but will try to answer questions about it or licensing. Contact us.
If you find issues or want to request enhancements, please use the issue tracker for each project (hosted on GitHub). Or better yet, fork the code and implement the feature/fix yourself, then submit a pull request.
Preferably use the GitHub repositories rather than zip archives to make it easier to get any updates.
You can also follow @dejalopen on Twitter to get notifications of updates, and/or subscribe to the RSS feed of the Dejal Blog filtered for Open Source topics.
DejalIntervalPicker is a custom Mac control similar to NSDatePicker, but for time intervals or ranges.

Features:
- A custom control with an amount or amount range, units, and stepper.
- Like
NSDatePicker, editing components separately, with a stepper. - Can set minimum and maximum amounts.
- Can get/set the interval as a
DejalInterval, as individual values, or as aNSTimeInterval. - Can have either a single amount or a range of amounts.
- Can optionally filter the range to ensure the first amount is smaller (or equal to) the second one, or vice versa.
- Can control which units to include.
- Can navigate between components via Tab and Shift-Tab and left/right arrow keys, or clicking.
- Can type amounts just like in the date picker, and units with auto-completion.
- Can increment and decrement amounts and units via up/down arrow keys, +/- keys, or the stepper.
- Can increment/decrement in steps of 5 via Shift/Option/Ctrl and up/down arrow keys, or Page Up/Down.
- Can go to the first/last valid values via Home/End.
- Can display a drop-down menu of suggested legal amounts or units via the spacebar or clicking on the selected value.
- Supports regular, small and mini sizes.
- Supports properties, key-value coding, and bindings.
- Supports
IB_DESIGNABLEandIBInspectable, so the picker can be configured in IB. - A demo project is included.
DejalObject is an abstract data model class that can represent subclasses as dictionary or JSON data for saving to disk or over the network.
Features:
- DejalObject: This is an abstract subclass of
NSObjectthat adds methods to represent the receiver as a dictionary or JSON data, load default values, track changes, enumerate an array ofDejalObjectinstances, and more. - DejalColor: A concrete subclass of
DejalObjectto represent a color (for macOS or iOS), enabling it to be stored in aDejalObjectsubclass. - DejalDate: Another concrete subclass to represent a date, primarily so it can automatically be represented as JSON.
- DejalInterval: A subclass to represent a time interval or a range of intervals, including an amount and units, with methods to represent the interval or range in various ways, including as human-readable strings (see also the
DejalIntervalPickerproject for macOS).
DejalUIKitCategories is a collection of categories for UIKit on iOS, to add useful methods to classes like UIBarButtonItem, UIColor, UIView, and others.
Features:
- UIApplication+Dejal: Adds methods to get the first responder and keyboard view of the app.
- UIBarButtonItem+Dejal: Convenience initializers to make
UIBarButtoninstances based on and image, title, system item, custom view, spacer, or segmented control. - UIButton+Dejal: A more convenient title property, and a method to add a gloss effect.
- UIColor+Dejal: Convenience initializers for more standard colors, or based on a platform-specific image or hex value.
- UIImage+Dejal: Convenience initializers for tinted images, methods to overlay images with colors, and scaling methods.
- UIImageView+Dejal: Make a white-background image view, and adjust the background color based on the highlighted state.
- UILabel+Dejal: Convenience initializers for labels with various text, font, width etc attributes, and sizing methods.
- UISegmentedControl+Dejal: Convenience initializer for a segmented control with specified items, target, action, and initial selection.
- UITextField+Dejal: A selected range property, and support for gestures to move the insertion point by swiping.
- UITextView+Dejal: Attributes of the selection or insertion point, and support for the insertion point swiping gestures.
- UIView+Dejal: Properties for frame and bounds components and an image representation, methods to hide, add to and remove from the superview with animation.
DejalAppKitCategories is a collection of categories for AppKit on macOS, to add useful methods to classes like NSMenu, NSTableView, NSTextView, and others.
Features:
- NSButton+Dejal: A text color property and a method to display a menu, plus methods to manage radio buttons without the informally-deprecated NSMatrix.
- NSImage+Dejal: Methods to draw flipped images, apply a badge or tint, or get a PNG representation.
- NSMenu+Dejal: Methods to add and remove items.
- NSOutlineView+Dejal: Methods for selected items and displaying a menu.
- NSPopUpButton+Dejal: Methods to add and select items.
- NSScreen+Dejal: Screen name methods.
- NSSplitView+Dejal: Methods for split positions and collapsing and expanding.
- NSTableView+Dejal: Selection, column and copying methods.
- NSTextField+Dejal: Methods to set values, synchronize with a slider, and resize the window (using autoresizing).
- NSTextView+Dejal: Properties for string, attributed string and RTF values, methods for length, range, appending, and selection.
- NSToolbar+Dejal: Methods for the toolbar height and finding an item by identifier.
- NSView+Dejal: Add a view as a fully-constrained subview, adjust autoresizing, scale, and set the alpha opacity.
- NSViewController+Dejal: Transition a view controller to another one as a fully-constrained subview.
- NSWindow+Dejal: Methods to force editing to end, fade in a window, and adjust the sizing of the window based on a view.
DejalAppKitExtensionCategories is a collection of categories to extend Foundation classes with methods specific to macOS.
Features:
- NSAttributedString+AppKit+Dejal: Adds convenience initializers to load from a bundle resource, image URL or RTF, and to return a RTF.
- NSDictionary+AppKit+Dejal: Extends
NSDictionaryandNSMutableDictionaryto supportNSColorvalues. - NSFileManager+AppKit+Dejal: Adds a method to determine if a path is a directory but not a package, and to move a file to the Trash.
- NSObject+AppKit+Dejal: Extends the
NSObjectbase class with an old-style modal did-end perform selector, and modifier key detection. - NSSString+AppKit+Dejal: Adds methods that depend on fonts, points and colors.
- NSUserDefaults+AppKit+Dejal: Adds support for points, sizes and colors in
NSUserDefaults.
DejalFoundationCategories is a collection of Foundation-level categories, to add useful methods to classes like NSArray, NSDictionary, NSString, and others.
Features:
- NSArray+Dejal: 30+ methods extending
NSArrayandNSMutableArray, including object matching, reversal, sorting, deep copying, adding and removing. - NSAttributedString+Dejal: 10+ methods extending
NSAttributedStringandNSMutableAttributedString, including convenience initializers, RTF and font methods. - NSData+Dejal: A couple of methods to make archiving and unarchiving objects slightly more convenient.
- NSDate+Dejal: 50+ methods extending
NSDate, including convenience initializers, handy date component properties and calculators, JSON date support, string formatting, and relative date output. - NSDictionary+Dejal: 25+ methods extending
NSDictionaryandNSMutableDictionary, including object matching, scalar support, deep copying, and more. - NSFileManager+Dejal: 15+ methods extending
NSFileManager, including convenient file attributes, file renaming, and path building. - NSObject+Dejal: 15+ methods extending the
NSObjectbase class, including key-value conveniences, “equivalent” comparisons, andperformSelectormethods. - NSString+Dejal: 80+ methods extending
NSStringandNSMutableString, including scalar value formatting, contains evaluation, comparisons, substring and range utilities, reformatting, checksum and encoding utilities, internet utilities, file path methods, and appending and replacing methods. - NSUserDefaults+Dejal: 15+ methods extending
NSUserDefaults, including support for default values, sanitizing values, time intervals, factory settings, and copying preferences.
DejalUtilities is a single header file with some useful #define macros and static functions.
Features:
- Adds
DejalClassAvailable()andDejalClassSelectorAvailable()macros, to help determine available APIs. - Adds
DejalIntervalFromMinutes(),DejalIntervalFromDays(),DejalMinutesFromInterval(),DejalMonthsFromInterval(), and similar macros, to convert seconds to and from other units. - Adds
DEJAL_FILE_NAMEandDEJAL_COMPILE_DATE_TIMEmacros, to help with debug information. - Adds a
DejalWeakSelfmacro to easily make a weak representation of self for use with blocks. - Plus several other handy macros and inline functions.
DejalBackgroundView is a NSView subclass to provide a background color and/or border color to a view.
Features:
- Adds a
drawsBackground BOOLproperty. Defaults toYES. - Adds a
drawsBorder BOOLproperty. Defaults toYES. - Adds a
backgroundColor NSColorproperty. Defaults tonil, but lazily assigns a light blue color if not set to another color. - Adds a
borderColor NSColorproperty. Defaults tonil, but lazily assigns a light gray color if not set to another color. IB_DESIGNABLEsupport for all four properties, so they can be set in Interface Builder.
DejalActivityView conveniently displays a horizontal, bezel-style, or keyboard-covering view with a spinning activity indicator and adjustable text.
Features:
- DejalActivityView: a simple horizontal-style loading view, intended for situations where you have a blank view while loading data.
- DejalWhiteActivityView: the same as the simple one, but with a white indicator and text instead of black, for use in dark views.
- DejalBezelActivityView: an animated round-rect-enclosed variation, with a gray background covering the parent view.
- DejalKeyboardActivityView: displays over the keyboard. Rarely used nowadays (and may be removed in a future version; let me know if you need it).
- A demo project is included.
DejalView is a UIView subclass to detect a tap outside a button (or other view) like UITableView's red Delete button.

(Contacts app)
Features:
- Adds a
viewDelegateproperty to the view. - If set, a
-view:hitTest:withEvent:hitView:method is invoked on the delegate. - That delegate method can return the passed view to act normally, or return
nilto ignore the tap.


