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 SwiftUI | |
public enum Enum1: Int, Codable, CaseIterable, CustomStringConvertible { | |
public var description: String { | |
return "\(rawValue)" | |
} | |
case one, two, three | |
} | |
public enum Enum2: String, Codable, CaseIterable, CustomStringConvertible { |
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 | |
class CodeTimer { | |
var startTime: CFAbsoluteTime = 0 | |
init() { start() } | |
func start() { startTime = CFAbsoluteTimeGetCurrent() } | |
func log(_ message: String) { | |
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime |
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) | |
} |
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
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 | |
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
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 | |
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 Foundation | |
protocol IOSDirectoryFile { | |
static var dirSelector: FileManager.SearchPathDirectory { get } | |
} | |
extension IOSDirectoryFile { | |
static var url: URL { | |
return FileManager.default.urls(for: dirSelector, in: .userDomainMask)[0] |
NewerOlder