This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func delay(delay:Double, closure:()->()) { | |
dispatch_after( | |
dispatch_time( | |
DISPATCH_TIME_NOW, | |
Int64(delay * Double(NSEC_PER_SEC)) | |
), | |
dispatch_get_main_queue(), closure) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct AppInfo { | |
static func buildNumber() -> String { | |
return AppInfo.infoDictionary["CFBundleVersion"] as! String | |
} | |
static func versionNumber() -> String { | |
return AppInfo.infoDictionary["CFBundleShortVersionString"]as! String | |
} | |
private static var infoDictionary: [NSObject: AnyObject] { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
/// Returns a boolean indicating whether the view's width is currently in regular mode | |
/// On iOS 7 this will return true when the device is an iPad and false on iPhone | |
func isHorizontalSizeClassRegularWidth () -> Bool{ | |
if self.respondsToSelector("traitCollection") { | |
return self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClass.Regular | |
} else { | |
return UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
func addConstaintsToPinHorizontalEdgesToSuperView(padding: CGFloat = 0) { | |
prepareForConstraints() | |
self.superview!.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-(padding)-[view]-(padding)-|", | |
options: NSLayoutFormatOptions(0), | |
metrics: ["padding":padding], | |
views: ["view":self])) | |
} | |
func addConstaintsToPinVerticalEdgesToSuperView(padding: CGFloat = 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Manages all the updates, inserts and deletes nicely so that you can worry about only the animation | |
/// @note Doesnt work with section changes as of yet | |
class CollectionViewFetchedResultsControllerDelegateCompanion: NSObject,NSFetchedResultsControllerDelegate { | |
var delegate: CollectionViewFetchedResultsControllerDelegateCompanionDelegate | |
private var changesKeyedByType:[NSFetchedResultsChangeType:[NSIndexPath]] = [:] | |
init(fetchedResultsController: NSFetchedResultsController,delegate: CollectionViewFetchedResultsControllerDelegateCompanionDelegate) { | |
self.delegate = delegate | |
super.init() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class var sharedInstance { | |
struct Static { | |
static let instance : SingletonObject = SingletonObject() | |
static var onceToken : dispatch_once_t = 0 | |
} | |
dispatch_once(&Static.onceToken) { | |
//perform configuration here | |
} | |
return Static.instance | |
} |
NewerOlder