View ManagementFunction.swift
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
// Management Function | |
func handleCarStarted() | |
{ | |
turnLights(on: true) | |
turnAC(on: true | |
} |
View RouterFunction.swift
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
// Router Function | |
private func turnLights(on shouldTurnLightsOn: Bool) | |
{ | |
if shouldTurnLightsOn | |
{ | |
turnExteriorLightsOn() | |
checkForBurnedBulbs() | |
} | |
else { turnExteriorLightsOff() } | |
// When an if statment has only 1 thing to execute i like to write it |
View ExecutionFunctions.swift
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
// Execution Functions | |
private func turnExteriorLightsOn() | |
{ | |
leftFrontLight .isOn = true | |
rightFrontLight.isOn = true | |
leftBackLight .isOn = true | |
rightBackLight .isOn = true | |
} | |
private func checkForBurnedBulbs() | |
{ |
View dateFormatterExample.swift
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
if let date = dateFormatter.parseDate(from: string) { | |
postUploadDate = date | |
} |
View DateFormatter.swift
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 DateFormatter | |
{ | |
private enum DateFormats: String, CaseIterable { | |
case basicDate = "yyyy-MM-dd" | |
case basicDateWithTime_Without_Miliseconds = "yyyy-MM-dd HH:mm:ss" | |
case basicDateWithTime_With_Miliseconds = "yyyy-MM-dd HH:mm:ss.SSSSS" | |
case basicDateWithTime_WithX_Miliseconds = "yyyy-MM-dd HH:mm:ss.SSSSx" | |
var withTimeStamp: String { | |
switch self { |
View parseDate.swift
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
func parseDate(from string: String?) -> Date { | |
guard let dateString = string else { return Date() } | |
if let date = self.date(from: dateString) { | |
return date | |
} | |
else { | |
return locateCorrectFormat(for: dateString) | |
} | |
} |
View locateCorrectFormat.swift
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
private func locateCorrectFormat(for dateString: String) -> Date { | |
for dateFormat in DateFormats.allCases { | |
if let date = parse(dateString, using: dateFormat) { | |
return date | |
} | |
} | |
return useRegexToExtractDate(from: dateString) | |
} |
View dataHasUpdated.swift
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
delegate.dataHasUpdated() | |
func dataHasUpdated() { | |
//Someone is informing you that something has happened | |
} |
View isPositionedVerticaly.swift
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 var isPositionedVerticaly: Bool { | |
return positionedVerticaly | |
} | |
if containerView.isPositionedVerticaly |
View positionedVerticaly.swift
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
private var positionedVerticaly: Bool { | |
return view.frame.width/2 == centerX | |
} | |
if positionedVerticaly | |
if positionedVerticaly && positionedHorizontally | |
VS | |
if isPositionedVerticaly | |
if isPositionedVerticaly && isPositionedHorizontally |
OlderNewer