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
import UIKit | |
/* ###################################################################################################################################### */ | |
// MARK: Fade Transition Animator | |
/* ###################################################################################################################################### */ | |
/** | |
This allows us to do a fade between two screens. | |
It was inspired by [this Medium post](https://medium.com/@ludvigeriksson/custom-interactive-uinavigationcontroller-transition-animations-in-swift-4-a4b5e0cefb1e) | |
*/ | |
open class RVS_FadeAnimator: NSObject, UIViewControllerAnimatedTransitioning { | |
/* ################################################################## */ |
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
import Foundation | |
public extension StringProtocol { | |
func containsOneOfThese(_ inCharacterset: CharacterSet) -> Bool { | |
self.contains { (char) in | |
char.unicodeScalars.contains { (scalar) in inCharacterset.contains(scalar) } | |
} | |
} | |
func containsOneOfThese(_ inString: String) -> Bool { |
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
extension UIView { | |
/* ################################################################## */ | |
/** | |
This allows us to add a subview, and set it up with auto-layout constraints to fill the superview. | |
- parameter inSubview: The subview we want to add. | |
*/ | |
func addContainedView(_ inSubView: UIView) { | |
addSubview(inSubView) | |
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
extension ITCB_SDK_Device_Peripheral: CBPeripheralDelegate { | |
public func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { | |
if let error = error { | |
print("Encountered an error \(error) for the Peripheral \(peripheral.name ?? "ERROR")") | |
owner?._sendErrorMessageToAllObservers(error: ITCB_Errors.coreBluetooth(error)) | |
return | |
} | |
print("Successfully Discovered \(peripheral.services?.count ?? 0) Services for \(peripheral.name ?? "ERROR").") | |
peripheral.services?.forEach { | |
print("Discovered Service: \($0.uuid.uuidString)") |
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
extension ITCB_SDK_Central { | |
override var _managerInstance: Any! { | |
get { | |
if super._managerInstance == nil { | |
print("Creating A new instance of CBCentralManager.") | |
super._managerInstance = CBCentralManager(delegate: self, queue: nil) | |
} | |
return super._managerInstance | |
} |
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
struct A<T: Hashable>: Hashable { | |
static func == (lhs: A<T>, rhs: A<T>) -> Bool { lhs.tVar == rhs.tVar } | |
let tVar: T | |
init(_ inVat: T) { | |
tVar = inVat | |
} | |
} |
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
// ########################################################## | |
// SET UP FOUR CONSTANT ARRAYS OF INT | |
// ########################################################## | |
let array1 = [0,1,2,3,4] | |
let array2 = [5,6,7,8,9] | |
let array3 = [10,11,12,13,14] | |
let array4 = [15,16,17,18,19] | |
// ########################################################## | |
// WE USE AN IMPLICITLY UNRWAPPED OPTIONAL |
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
protocol P { | |
func printAhh(); | |
} | |
// Default implementation | |
extension P { | |
func printAhh() { | |
print("AHHH...") | |
} | |
} |
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
/* | |
<containerElement> | |
<arrayElement>Element Value 01</arrayElement> | |
<arrayElement>Element Value 02</arrayElement> | |
<arrayElement>Element Value 03</arrayElement> | |
<arrayElement>Element Value 04</arrayElement> | |
<arrayElement>Element Value 05</arrayElement> | |
</containerElement> | |
<!-- |
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
// This is a completely generic protocol. You can use any type for "T". | |
protocol GenericBaseProtocol { | |
associatedtype T | |
var myProperty: T {get set} | |
init(_ myProperty: T ) | |
} | |
// You can declare both Comparable and non-Comparable types with this protocol. | |
// This is Comparable |
NewerOlder