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
let now = Date() | |
var future = now | |
print("equal: \(now == future)") | |
// equal: true | |
future += 1 * 60 * 60 | |
print("not equal: \(now == future)") | |
// not equal: false | |
future -= 2 * 60 * 60 | |
print("now > future?: \(now > future)") |
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
var date = Date(timeIntervalSince1970: 50 * 365 * 24 * 60 * 60) | |
print("date: \(date)") | |
// console: date: 2019-12-20 00:00:00 +0000 |
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
enum EmailValidationError: Error { | |
// TODO: - Cases | |
case empty | |
// TODO: - Cases can be declared on a single line | |
case noDomain(String) | |
case invalid(String) | |
} | |
extension EmailValidationError: LocalizedError { | |
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
enum Weekday: Int { | |
case sun | |
case mon | |
case tue | |
case wed | |
case thur | |
case fri | |
case sat | |
var value: String { |
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
enum EmailValidationError { | |
// TODO: - Cases | |
case empty | |
// TODO: - Cases can be declared on a single line | |
case noDomain(String) | |
case invalid(String) | |
} | |
// TODO: - Create a new error | |
var error = EmailValidationError.empty |
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
enum EmailValidationError: CaseIterable { | |
// TODO: - Cases | |
case empty | |
// TODO: - Cases can be declared on a single line | |
case noDomain, invalid | |
} | |
print("All cases: \(EmailValidationError.allCases)") | |
// TODO: - Just print all enum cases |
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
switch error { | |
case .empty: | |
print("Please provide email") | |
case .noDomain: | |
print("Add domain") | |
case .invalid: | |
print("Entered email looks like invaid") | |
} | |
if signupError == .invalid { |
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
// TODO: - Create a new error | |
var error = EmailValidationError.empty | |
// TODO: - OR type-inferred | |
var signupError: EmailValidationError = .invalid | |
error = .noDomain |
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
enum EmailValidationError { | |
// TODO: - Cases | |
case empty | |
// TODO: - Cases can be declared on a single line | |
case noDomain, invalid | |
} |
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
@IBInspectable | |
var activeSegmentColor: UIColor = .segmentActiveBackground | |
@IBInspectable | |
var textColor: UIColor = .segmentText | |
@IBInspectable | |
var activeTextColor: UIColor = .segmentActiveText |