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
// A Playground that shows how to use protocol extensions to do Dependency Injection | |
import UIKit | |
import PlaygroundSupport | |
enum InjectorType: String { | |
case mainType | |
case mocType | |
} |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
import PlaygroundSupport | |
extension UIColor { | |
class func with(hex: UInt, alpha: Float = 1.0) -> UIColor { | |
return UIColor(colorLiteralRed: Float((hex & 0xFF0000) >> 16)/255.0, | |
green: Float((hex & 0x00FF00) >> 8)/255.0, | |
blue: Float((hex & 0x0000FF) >> 0)/255.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
//: Playground - noun: a place where people can play | |
import UIKit | |
import Foundation | |
import PlaygroundSupport | |
class IndexCardView: UIView { | |
let topSpacing: CGFloat = 80.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
//: Playground - noun: a place where people can play | |
import UIKit | |
var hits = [Int: Bool]() | |
func collatz(_ n: Int) { | |
if n == 1 { return } | |
var new: Int! | |
if (n % 2) == 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
//: Playground - noun: a place where people can play | |
import UIKit | |
var str = "Hello, playground" | |
let a = ["a", "b", "c"] | |
let b = ["d", "e", "f"] | |
let c = ["g", "h", "i"] | |
let aa = [a, b, c] |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
var str = "Hello, playground" | |
struct ChartItem { | |
var label: String = "" | |
var value: CGFloat = 0.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
//: Playground - noun: a place where people can play | |
import UIKit | |
import PlaygroundSupport | |
class BarGraphView: UIView { | |
lazy var greenBar: UIView = { | |
let view = UIView(frame: .zero) | |
view.translatesAutoresizingMaskIntoConstraints = 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
//: Playground - noun: a place where people can play | |
import UIKit | |
import PlaygroundSupport | |
var str = "Hello, playground" | |
extension UIImage { | |
class func circle(diameter: CGFloat, color: UIColor) -> UIImage? { |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
import PlaygroundSupport | |
class IndexCardImageView: UIImageView { | |
let topSpacing: CGFloat = 80.0 | |
var lineColor = UIColor.clear | |
var lineWidth: CGFloat = 1.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
//: Playground - noun: a place where people can play | |
import UIKit | |
/* | |
* Description: a String extension to convert roman numerals to their respective integer values | |
* Synopsis: | |
* Any of the letters representing numbers in the Roman numerical system: | |
* | |
* I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, M = 1,000. |
NewerOlder