Dejal Open Source
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.
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.
Get a Non-Attribution License
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.
Get In Touch!
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.
Keep Up To Date
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.
- A custom control with an amount or amount range, units, and stepper.
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 a
- 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.
IBInspectable, so the picker can be configured in IB.
- A demo project is included.
DejalObject (macOS & iOS)
DejalObject is an abstract data model class that can represent subclasses as dictionary or JSON data for saving to disk or over the network.
- DejalObject: This is an abstract subclass of
NSObject that adds methods to represent the receiver as a dictionary or JSON data, load default values, track changes, enumerate an array of
DejalObject instances, and more.
- DejalColor: A concrete subclass of
DejalObject to represent a color (for macOS or iOS), enabling it to be stored in a
- 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
DejalIntervalPicker project for macOS).
DejalUIKitCategories is a collection of categories for UIKit on iOS, to add useful methods to classes like
UIView, and others.
- UIApplication+Dejal: Adds methods to get the first responder and keyboard view of the app.
- UIBarButtonItem+Dejal: Convenience initializers to make
UIBarButton instances 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
NSTextView, and others.
- 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.
- 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
NSMutableDictionary to support
- 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
NSObject base 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
DejalFoundationCategories (macOS & iOS)
DejalFoundationCategories is a collection of Foundation-level categories, to add useful methods to classes like
NSString, and others.
- NSArray+Dejal: 30+ methods extending
NSMutableArray, including object matching, reversal, sorting, deep copying, adding and removing.
- NSAttributedString+Dejal: 10+ methods extending
NSMutableAttributedString, 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
NSMutableDictionary, 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
NSObject base class, including key-value conveniences, “equivalent” comparisons, and
- NSString+Dejal: 80+ methods extending
NSMutableString, 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 (macOS & iOS)
DejalUtilities is a single header file with some useful
#define macros and static functions.
DejalClassSelectorAvailable() macros, to help determine available APIs.
DejalMonthsFromInterval(), and similar macros, to convert seconds to and from other units.
DEJAL_COMPILE_DATE_TIME macros, to help with debug information.
- Adds a
DejalWeakSelf macro 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.
- Adds a
drawsBackground BOOL property. Defaults to
- Adds a
drawsBorder BOOL property. Defaults to
- Adds a
backgroundColor NSColor property. Defaults to
nil, but lazily assigns a light blue color if not set to another color.
- Adds a
borderColor NSColor property. Defaults to
nil, but lazily assigns a light gray color if not set to another color.
IB_DESIGNABLE support 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.
- 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.
- Adds a
viewDelegate property 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
nil to ignore the tap.