README.md

About

this is a VERY loose collection of individual classes and/or components for OSX/IOS that I find myself reusing serveral times and so thought it that it might be good to make them available.

Most of the classes are aren't meant or even guaranteed to be feature complete. The newer ones all have small demo apps though :D Originally, they were developed for a very specific use case. They were/are all used in one or the other published app and then I thought I'd make them available to the general public.

new classes will be in swift (and sometimes in objC as well) but the 'old' objective-C classes are useful and still up to date too and I won't port all old code.

DDRequestQueue [ios+osx] + demo - An easy class to queue up NSURLRequests that are processed when the app has a valid network connection. The requests are even persisted and the queue continues whenever it starts up again. It uses NSURLSession for the requests.

DDMultiDateFormatter [ios+osx] + demo - A NSFormatter subclass that wraps multiple date formatters. This 'compound' date formatter by default adheres to RFC3339 but can be used to understand all kind of date formats.

NSURLConnection+ModifiedSince [ios+osx] + demo - A category on NSURLConnection that provides an easy to use convenient method to Get & Cache Data (Using Modified-Since HTTP) [the demo is for IOS. the objC version's demo is for OSX.

DDPermutation [ios+osx + demo] - adds a Helper to build index sets that are random but the indices remain unique and the sets (reproducibly). Wraps around arrays and can be used in a for in loop with arrays via the global method `permutate`

NSUserDefaults+RunOnce [ios + osx] - extension on user defaults to add a convenience method to run a specified closure only once per user (e.g. some legal info popup needs to be shown only once, or a tutorial or a certain system check).

UIViewController+Dummy [ios + demo] - Helper that swizzles viewWillAppear and adds a navbar and buttons for all segues as needed! This is meant to be used during development only. At the beginning of development work you can 'test' out your storyboard flow.(segues need to have ids!)

MovieView [ios + demo] - A UIView subclass that is IBDesignable and can show a movie (any format AVKit can handle should do) It can transparently use device specific videos (-ipad or -iphone) if provided.

DDContentZoomSegue [ios + demo] A custom segue that can be pushed / present modally using an 'expand/scale to reveal' animation. It takes into account the sender's placement for the best effect

DDSlidingImageView [ios + demo] - View class that shows a UIImage (same as an imageView) but also supports 'covering it' by animating color to cover non-transparent areas of the image using a color. So it can do an animated 'colorize' of the image shown. I use it for FILLING effects. It uses CADisplayLink and also shows hhow to make a view IBDesignable. A Demo showing a configured view is included and the demo app shows the intrinsic animation

ObjC

model-related:

DDRequestQueue [ios+osx] - An easy class to queue up NSURLRequests that are processed when the app has a valid network connection. The requests are even persisted and the queue continues whenever it starts up again. It uses NSURLSession for the requests.

DDMultiDateFormatter [ios+osx] + demo - A NSFormatter subclass that wraps multiple date formatters. This 'compound' date formatter by default adheres to RFC3339 but can be used to understand all kind of date formats.

NSURLConnection+ModifiedSince [ios+osx] + demo - A category on NSURLConnection that provides an easy to use convenient method to Get & Cache Data (Using Modified-Since HTTP) [the demo is for OSX. the swift verion's demo is for ios.

DDEmbeddedDataReader [ios+osx] + demos - Based on code from BVPlistExtractor by Bavarious, this class allows easy reading of embedded (linked in) data from any executable. (e.g. a CLI Tool's plist included using the linker flag `-sectcreate __TEXT __info_plist TestInfo.plist`)

DDMicBlowDetector [ios] + demo - one class that worries about getting microphone input and making 'sure' that the sound is a blowing/hissing sound… not some random music. (the confidence value for this can be set, as well as min/max durations)
The basic algorithm is based on a tutorial from Mobile Orchad by Dan Grigsby.

DDFilterableArray [ios+osx] + demo - basic Subclasses of NSArray and NSMutableArray AND a category on NSArray to make a Array class that you can easily filter by passing a predicate format string or a predicate inside of the brackets. (This is great for parsers, see xsd2cocoa for a real life usage)

DDRecentItemsManager [ios+osx] + demo - simple wrapper that stores a list of items (NSDictionaries). The array is trimmed to a user-definable maximum (on osx it uses NSDocumentController, on ios it is set to 10 by default). The list is persisted as a plist in the ApplicationSupport directory.

DDTask [osx] + demo - 'Replacement' for NSTask that can be run multiple times in any operation / any thread. It tries to get a successful result N times and returns the result of stdout or nil.

DDRunTask [osx] - 'Easy convenience' function for running a NSTask in a single line. Run a command just like you'd enter it on the console - quick'n'dirty ;)

DDXcodeProject [osx] + demo - A class that wraps a XCode project file. It extracts the basic project variables (name, orga, language, _resolved_ root dir) but it doesnt yet look up targets or files. It uses reflection for the parsing.. also nice. Ive first seen it in AQXMLParser :)

M42AbstractCoreDataStack [ios+osx] - offers a simple core data wrapper (if one doesnt want to use the really good library MagicalRecord)

M42RandomIndexPermutation [ios+osx] + demo - Helper to build index sets that are random but the indices remain unique and the sets (reproducibly).

NSFileManager+Count [osx] - (Cocoa wrapper for legacy but fast carbon way of counting files in a folder )

NSString+advancedSplit [ios+osx] + demo - A 'smarter' version of componentsBySplittingString. It never breaks inside of quotes and respects escaped strings.

NSDictionary+PostData [ios+osx] - Provides a method to get POST Data from a dictionary it supports NSStrings and NSData(!) [it creates multipart post]

NSObject+DDDump [ios+osx] + demo - provides a dictionary with reflected information about the class (superclass, protocols, ivars, properties, methods). The category also has a 'dump' method to assemble the data into a NSString that you can output.

SKPaymentQueue+TransactionForProduct [ios+osx] - Category to search in a PaymentQueue for (any / first successful[restored or not]) transaction for a given product identifier.

NSWorkspace+runFileAtPath [osx] - category that provides a method to run any file. It can be an Applescript (NSApplescript is used), a shell script or exectuable (NSTask is used), a file wrapper or app (NSWorkspace is used) or a directory (is opened with the finder). Specified arguments are passed to the Apple Scripts, Shell scripts, to apps and to unix executables.

NSArray+DDPerformAfterDelay [ios+osx] - Category on NSArray to easily call makeObjectsPerformSelector after a delay

NSManagedObjectContext+RefreshObjectRecursive [ios+osx] - Category on the context to allow to refresh an object RECURSIVELY. The normal refreshObject method isn't recursive.

NSOperation+Duration [ios+osx] + demo - Category that adds a duration property to ANY NSOperation. (The included test app shows this working with AFNetworking!)

NSOperation+UserInfo [ios+osx] + demo - Category that adds a userInfo dictionary property to ANY NSOperation. (The included test app shows this working with AFNetworking!)

NSObject+MethodSwizzle [ios+osx] + demo - I found myself doing a lot of swizzling recently, so I added this category. I especially like mikeash's neat trick of swizzling a method of ANY class with a C Function you provide!

UIFont+RegisterURL [ios] - This category enables you to load a UIFont from ANY url. The url can be local or remote. It can also point to local a folder (or a NSBundle) to load fonts from there :) Last but not least it provides a convenience method fontWithName:size:ifNeededLoadURL:

DDOpenAtLoginController [osx] - This class provides a single property. 'appStartsAtLogin' It adds/removes the current app from the login items list. That bool is bindable and and reflects the system preferences.

DDLMUService [osx] - A wrapper for the undocumented IOKit LMUService: The 'kernel driver' for the ambient light sensor AND the LED Backlight of Macbooks (only tested under 10.9 on MBP 2011 but should work for any Macbook able to run 10.8+)

DDLanguageConverter [ios+osx]Class to convert between apple language codes to iso6392 language codes or iso3166a3 country codes. Also includes two categories for NSLocale to ease development.

DDXMLValidator [ios + osx] + demo - Component that validates a given XML file (local or remote) against a Schema (which can be XSD, DTD or RNG.) (It uses libxml2 for the validation and is based on code by Todd Ditchendorfer.)

NSObject+isValidPlist [ios+osx] - Quick category on NSObject to see if it a plist type and if it is an array or dictionary if it only contains plist objects

ui-related:

UIViewController+Dummy [ios] + demo - Helper that swizzles viewWillAppear and adds a navbar and buttons for all segues as needed! This is meant to be used during development only. At the beginning of development work you can 'test' out your storyboard flow.(segues need to have ids!)

UIImage+AssertNamed [ios] - Helper that swizzles imageNamed and assert the image can be found! This is meant to be used during development only

DDImage+Masked [ios+osx] - Category for both UIImage and NSImage that simplifies masking one image with another one. (It hides all the 'annoying ;)' CoreGraphics code)

M42TabBarController [ios] - A tab bar that has a 'disabled' property and can draw with a 'black translucent' overlay to signal its status.

M42WebViewController [ios] - A view controller that manages a webview. It displays loading labels and offers a back button if appropriate

M42WebviewTableViewCell [ios + demo] - Interesting cell that displays html content and tells the controller its required size. A Demo using a minimal tabeView is included.

NSWindow+localize [osx] - Category on NSWindow that localizes itself and all its subviews. (knows many defacto default selectors so it works with many views out-of-the-box)

NSWindow+Fade [osx] - Category on NSWindow that adds fadeIn and fadeOut actions that work like animated order in order out

NSView+findSubview [osx] - Category on NSView that provides aa method to find a(or many) subview (by class and or tag) in its subview-tree.

UIView+didAddSubview [ios] - Category on UIView that swizzles in a delegate that gets always called after the view's own didAddSubview method. You no longer have to subclass a view because you need didAddSubview! (needs NSObject+MethodSwizzle!)

UIView+findSubview [ios] - Category on UIView that provides methods to find a(or many) subview (by class and or tag) in its subview-tree.

UIView+Border [ios] - Category on UIView that provides a simple wrapper around CALayer allowing to easily add a border around a view.

DDSlidingImageView [ios + demo] - View class that shows a UIImage (same as an imageView) but also supports 'covering it' by animating color to cover non-transparent areas of the image using a color. So it can do an animated 'colorize' of the image shown. I use it for FILLING effects. It uses CADisplayLink and also shows hhow to make a view IBDesignable. A Demo showing a configured view is included and the demo app shows the intrinsic animation