Skip to content

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.

License

Daij-Djan/DDUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Individual Classes

Swift (all updated for swift 3.0)

model-related:
  • BeaconManager [ios + demo] An easy to use iBeacon monitor
  • URLSession+ModifiedSince [ios+osx] + demo - A category on URLSession that provides an easy to use convenient method to Get & Cache Data (Using Modified-Since HTTP) [the demo is for IOS].
  • GoogleSpeechSession [ios + osx + demo] - Class that wraps AVRecorder/AVAudioPlayer and provides a very easy to use interface to leverage the SYNCHRONOUS REST-based Google Cloud Speech API (Note: You will need a Google Cloud API Key!)
  • Color+rgbaString [ios+osx] - Extension that adds a property & constructor to stringify a color.
  • EWSProfileImage [ios+osx] + Demo - Class that will load & cache profile images from an exchange server
  • ReflectionHelper [osx + ios + demo] - an objC and a swift ReflectionHelper that allows even getting values of _SwiftValues or properties not marked for objC (incl. enums) across languages if needed and without knowing knowing any prototypes
  • CLPlacemark+CNPostalAddress [ios + osx] - An extension to get a CNPostalAddress from a placemark (cl or mk) that can be used to get a formatted address string in current IOS
  • NotificationObserver [ios+osx] + demo - Makes observing a NSNotificationCenter easy, convenient and more swift like.
  • 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).
ui-related:
  • AutoshrinkWithWordWrap [ios + demo] - Two categories (on String and UILabel) that correctly autoshrink multi-line text that contains a long word like 'Congratulations' which is shrunk but not split in between. The Multi-Line label honours the Word-Wrap property.
  • HTMLHelpers [ios + demo] - three categories that add setHTMLText methods to Buttons, Labels and TextViews
  • RingsView [ios + demo] - a UIView subclass that draws customizable, colored, pulsating rings around any given UIView! The view remains interactable.
  • CloudEmitterView [ios + demo] - a view that shows moving clouds -- like in a sky. It shows how to use a CAEmitterLayer
  • ScrollingStackView [ios + demo] - A drop in replacement for UIStackView that automatically adds scrolling if needed
  • 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
  • DDRectUtilities [ios+osx] - Utility class with useful scaling/placement methods for CGRects
  • 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 version's demo is for ios.
  • ReflectionHelper [osx + ios + demo] - an objC and a swift ReflectionHelper that allows even getting values of _SwiftValues or properties not marked for objC (incl. enums) across languages if needed and without knowing knowing any prototypes
  • DDUnits [ios+osx] + demo - A class to quickly convert between formatted strings and numbers for units.
  • NSFileManager+DataProtection [ios] - A category to quickly add data protection to a file
  • NSFileManager+SkipBackupAttributeToItemAtPath [ios] - A category to exclude a file from an iTunes backup. (With apples storage guidelines, this is often important)
  • DDSocialMessenger [ios+osx] - provides easy-to-use methods to post to twitter or facebook or both! It encapsulates all dealings with accounts and social framework
  • BonjourServicesBrowser [ios+osx] - asynchronously finds services using NSNetServiceBrowser
  • DDPowerMonitor [osx] - easy monitor power mode (battery / ac / charging) and system sleep/wake
  • DBPrefsWindowController [osx] - a window controller that is tailored for doing preferences windows. (has a tabbar, crossfades. Meant to be subclassed. Based on class by Dave Batton)
  • DDASLQuery [ios+osx] + demo - wraps the C apis for querying ASL (default log on ios4+ or 10.6+)
  • DDChecksum [ios+osx] + demo - wraps the C api for building checksums (from apple's CommonCrypto library)
  • 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)
  • NSObject+TransparentKVC [ios+osx] + demo - use @protocols for typesafe KVC. E.g. for Accessing parsed JSON (nested NSDictionaries) [clean, concise, effective, self documenting, see the Demo for a better explanation of this concept]
  • 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.
  • NSString+ValidateEmail [ios+osx] + demo - Check if a NSString object represents a valid email. Uses some regex.
  • 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+)
  • DDUserNotificationCenterMonitor [osx] - Component that monitors the global MTNLion notification center. (It uses SCEvents to monitor disk changes and FMDB to read the Notification Center's SQLite database.)
  • 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.)
  • DDAppStoreInfo [ios+osx] + demo - Component that shows how to easily fetch information from the appstore via the Apple iTunes Lookup API
  • 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)
  • DDRectUtilities [ios+osx] - Utility class with useful scaling/placement methods for CGRects
  • DDAddressPicker [osx] +demo - A Window controller that offers a PeoplePicker allowing to pick persons from the address book. Adding some Features commonly needed
  • M42ActionSheet [ios] - Drop In Replacement for UIActionSheet with support for custom colored buttons. (specifically we wanted a green one!)
  • M42ClickableImagview & Label [ios] - Subclasses that have action & target and react to touches
  • M42LoadingScreenViewController [ios] - Black screen, White 'Loading...', spinner, progress bar :) Looks a bit like the iOS Startup screen
  • M42PieChartView [ios] - A UIView that displays a 2D PieChart (for more graphing options, look into CorePlot)
  • M42PinchableWebView [osx] - Subclass of WebView which handles zooming in response to pinch gestures.
  • 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.
  • NSWorkspace+IconBadging [osx] + demo - Category on NSWorkspace that allows setting icon badges on files/folder (like dropbox or torquoise SVN). (wraps carbon's IconServices API for that)
  • NSAttributedString+DDConvenience [ios+osx] - Category on NSAttributedString to create it from printf like varargs (like stringWithFormat:)
    On OSX there's also attributedStringWithImage.
  • UIAlertView+UserInfo [ios] - Category on UIAlertView that adds a userInfo NSDictionary property to the alert that you can set and get (like it works for NSTimer)
  • UIImage+DDBadge [ios] - Category on UIImage that returns a badged copy of an image. The look of the badge is customizable to a certain degree
  • UIImage+DefaultImage - Category on UIImage to easily get the Current App's Default image (the correct version for the Current Device)
  • DDTextField [ios + demo] - Interesting compound class that provides a common interface for single-line UITextFields and multi-line UITextViews. A Demo showing some differently configured textfields is included. (and the class shows how IBDesignable and IBInspectable works)
  • 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


License

The Code is completely available under MIT

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published