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
enum Roman: String { | |
case M, D, C, L, X, V, I | |
init(_ v: String) { | |
self.init(rawValue: v)! | |
} | |
} | |
extension Roman { | |
var int: Int { |
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 | |
extension Date: ExpressibleByStringLiteral { | |
public init(stringLiteral value: String) { | |
let formatter = DateFormatter() | |
formatter.dateFormat = "dd-MM-yyyy" | |
formatter.timeZone = TimeZone(secondsFromGMT: 0) | |
self = formatter.date(from: value)! | |
} | |
} |
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
prefix operator ?? | |
prefix func ??(s: String) -> String { | |
return NSLocalizedString(s, comment: "") | |
} | |
??"Awesome string here" |
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
extension Date { | |
var age: Int { | |
return Calendar.current.dateComponents([.year], from: self, to: Date()).year! | |
} | |
} | |
extension DateFormatter { | |
static func getDateFormatter() -> DateFormatter { | |
let df = DateFormatter() | |
df.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.sssZ" |
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
// MARK: - Protocols | |
protocol User { | |
var name: String { get } | |
var email: String { get } | |
var address: String { get } | |
var line1: String? { get } | |
var line2: String? { get } | |
} |
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
// MARK: - Protocols | |
protocol Person { | |
var name: String { get } | |
} | |
protocol User { | |
var identifier: String { get } | |
var email: String { get } | |
} |
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 | |
let myDate = """ | |
{ | |
"name": "jr", | |
"data": "sjkdhfjsdhf", | |
"updated":"2017-10-10 10:38:25.722 UTC" | |
} | |
""" |