TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Mar 2016 |
Maintained by Evan Maloney.
The Mockingbird Toolbox is a set of general-purpose utility code for use in iOS and Mac OS X applications.
The Toolbox is the lowest-level module in the Mockingbird Library open-source project from Gilt Groupe.
The Mockingbird Toolbox includes:
The MBBatteryMonitor
class (iOS only) reports the device’s power status and battery level, and also posts events through the NSNotificationCenter
when these values change.
The MBNetworkMonitor
class provides details about the current status of the device’s wifi and (if available) carrier network, and can also be configured to post NSNotificationCenter
events as network status changes occur.
Mockingbird Toolbox provides a simple but extensible caching architecture.
The MBThreadsafeCache
class implements a basic memory cache that can be safely shared across threads.
A subclass, MBFilesystemCache
, adds a filesystem backing store to the memory cache.
The MBConcurrentReadWriteCoordinator
class uses Grand Central Dispatch to provide an efficient mechanism for enforcing orderly read/write access to a shared resource.
MBThreadLocalStorage
provides an interface for safely sharing thread-local storage among unrelated units of code. The class can also be used as a lock-free cache: Objects that are expensive to create, such as NSDateFormatter
instances, can be cached in thread-local storage without incurring the locking overhead required by a shared object cache like MBThreadsafeCache
.
The Mockingbird Toolbox provides NSString
and NSMutableString
class extensions to help create, manipulate, and execute regular expressions.
These extensions make use of the MBRegexCache
for reusing regular expressions, which can be expensive to create.
The MBMessageDigest
class provides a high-level API for generating MD5 and SHA-1 secure one-way hashes from strings, NSData
instances, byte arrays, and files.
Class extensions for NSString
and NSData
are also provided to simplify creating message digests from existing objects.
The MBNetworkIndicator
class (iOS only) provides a mechanism to coordinate the display of the status bar network activity indicator.
Mockingbird Toolbox includes various utilities for creating, examining, and manipulating colors.
The Toolbox contains a UIImage
class extension that adds methods for scaling images, as well as a UIView
class extension for capturing the contents of a view as a UIImage
, CIImage
or CGImageRef
.
The MBBitmapPixelPlane
class represents a plane of pixels that can be accessed individually, regardless of the underlying pixel format. This allows direct extraction and manipulation of pixel data within a bitmap.
That’s just a quick summary.
For further details, start with the Mockingbird Toolbox API documentation.
Although you can directly add some or all of the source files in Mockingbird Toolbox to an existing project, we recommend using CocoaPods for integration.
CocoaPods will let you include only those portions of Mockingbird Toolbox that you actually wish to use, and it also gives you a simple way to keep up-to-date with any critical changes while providing versioning capabilities if you need to remain locked to a specific release or range of releases.
When you integrate Mockingbird Toolbox using CocoaPods, you should reference header files using the “library header” import notation, eg.:
#import <MBToolbox/MBDebug.h>
In the future, we may issue binary releases of Mockingbird Toolbox as frameworks; using the notation above will allow you to seamlessly transition to using a framework.
If you are not using CocoaPods and are instead copying the Mockingbird Toolbox source into your project directly, you will need to reference those headers with “user header” notation:
#import "MBDebug.h"
If you only want to use some of what's available in the Toolbox, we've provided a number of CocoaPod subspecs that allow you to pick and choose exactly what you want to use from Mockingbird Toolbox.
Subspecs are added to your Podfile
as follows:
pod 'MBToolbox/BatteryMonitor'
pod 'MBToolbox/BitmapPixelPlane'
The lines above would add just the BatteryMonitor and BitmapPixelPlane portions of the Mockingbird Toolbox to your project.
Among the subspecs provided are:
MBBatteryMonitor
class and related itemsMBThreadsafeCache
class and related itemsMBFilesystemCache
class and related itemsMBConcurrentReadWriteCoordinator
classMBThreadLocalStorage
classMBFieldListFormatter
classMBFieldListFormatter
and MBFormattedDescriptionObject
classesMBBitmapPixelPlane
class and related itemsMBRoundedRectTools
classUIColor
class extension that adds several methods for getting information about and modifying colorsUIImage
class extension that adds methods for scaling imagesUIView
class extension that adds methods for acquiring image snapshots of a view's contentsMBMessageDigest
classMBMessageDigest
class and an NSString
class extension providing related convenience methodsMBMessageDigest
class and an NSData
class extension providing related convenience methodsMBMessageDigest
class and all related class extensionsMBNetworkIndicator
classMBNetworkMonitor
service, a high-level replacement for Reachability
that provides additional functionalityMBOperationQueue
classMBOperationQueue
class and various filesystem operationsMBRegexCache
singletonNSString
and NSMutableString
that provide convenience methods for handling regular expressions using the MBRegexCache
for improved performanceMBServiceManager
singleton and the MBService
protocolMBSingleton
and MBInstanceVendor
protocols, and the preprocessor macro MBImplementSingleton()
which provides a default singleton implementation based on dispatch_once()
MBForceString()
and MBTrimString()
inline functions, and the MBStringify()
preprocessor macroNSData
class extension that adds methods for converting between hexadecimal strings and NSData
instances, and also provides methods for interpreting NSData
instances as byte data for NSString
s of various encodingsNSString
class extension that adds methods for indenting the individual lines in a string using tabs and arbitrary prefixesUIFont
class extension that adds methods for performing common text measurement tasksAdditional subspecs are declared and documented in the podspec.
The Mockingbird Toolbox represents the foundation of the Mockingbird Library.
Over the years, Gilt Groupe has used and refined Mockingbird Library as the base platform for its various iOS projects.
Mockingbird began life as AppFramework, created by Jesse Boyes.
AppFramework found a home at Gilt Groupe and eventually became Mockingbird Library.
In recent years, Mockingbird Library has been developed and maintained by Evan Coyne Maloney, Distinguished Engineer at Gilt Tech.
Mockingbird Library and Mockingbird Toolbox © Copyright 2009-2015, Gilt Groupe.
Licensed under the MIT license.