This file contains 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
// | |
// UIColor.swift | |
// previously Color+HexAndCSSColorNames.swift | |
// | |
// Created by Norman Basham on 12/8/15. | |
// Copyright ©2018 Black Labs. All rights reserved. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights |
This file contains 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
import Foundation | |
public class ThreadUtil : NSObject { | |
// Run a block on the main thread after a specified number of seconds, thanks raywenderlich.com for splaining it so well | |
public static func runOnMainThreadAfterDelay(delaySeconds: Double, closure: () -> ()) { | |
let startTime = dispatch_time(DISPATCH_TIME_NOW, Int64(delaySeconds * Double(NSEC_PER_SEC))) | |
dispatch_after(startTime, dispatch_get_main_queue(), closure) | |
} |
This file contains 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
import Foundation | |
protocol IOSDirectoryFile { | |
static var dirSelector: FileManager.SearchPathDirectory { get } | |
} | |
extension IOSDirectoryFile { | |
static var url: URL { | |
return FileManager.default.urls(for: dirSelector, in: .userDomainMask)[0] |
This file contains 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
import UIKit | |
public extension Sequence { | |
// return true if all elements return true | |
func every<T>(predicate:(T) -> Bool) -> Bool { | |
for item in self { | |
if !predicate(item as! T) { | |
return false | |
} |
This file contains 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
import StoreKit | |
public extension SKProduct { | |
convenience init(d : Dictionary<String, AnyObject>) { | |
self.init() | |
self.setValue(d["uid"], forKey: "productIdentifier") | |
self.setValue(d["title"], forKey: "localizedTitle") | |
self.setValue(d["detail"], forKey: "localizedDescription") | |
self.setValue(NSDecimalNumber(string: (d["price"] as! String?)), forKey: "price") |
This file contains 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
import UIKit | |
import PlaygroundSupport | |
public class DeviceViewController : UIViewController { | |
public enum ScreenType : Int { | |
case iPhone3_5Inch | |
case iPhone4Inch // includes 5th & 6h gen iPod Touch | |
case iPhone4_7Inch | |
case iPhone5_5Inch |
This file contains 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
public extension Sequence { | |
// return true if all elements return true | |
func every<T>(predicate:(T) -> Bool) -> Bool { | |
for item in self { | |
if !predicate(item as! T) { | |
return false | |
} | |
} | |
return true |
This file contains 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
import UIKit | |
public extension UIView { | |
public var top: CGFloat { | |
get { return self.frame.origin.y } | |
set { self.frame.origin.y = newValue } | |
} | |
public var left: CGFloat { | |
get { return self.frame.origin.x } |
This file contains 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
import Foundation | |
extension Date { | |
static func randomBetween(start: String, end: String, format: String = "yyyy-MM-dd") -> String { | |
let date1 = Date.parse(start, format: format) | |
let date2 = Date.parse(end, format: format) | |
return Date.randomBetween(start: date1, end: date2).dateString(format) | |
} |
OlderNewer