Skip to content

Instantly share code, notes, and snippets.

View EricADockery's full-sized avatar
🦕

Eric Arlan Dockery EricADockery

🦕
  • Versailles, KY
View GitHub Profile
@EricADockery
EricADockery / Fastfile
Created July 25, 2017 16:42
Parallel iOS Testing using Bluepill
lane :bluepill do
scan(scheme: “myApp”, build_for_testing: true)
sh “bash ./bluepill.sh“
end
@EricADockery
EricADockery / SectionTitleEnumExample.swift
Created February 7, 2018 22:36
Example to creating multiple titles for headers in section given different layout options
enum SectionTitle: String {
case a = "a"
case b = "b"
case c = "c"
case d = "d"
init?(section: Int, hasB: Bool = false, hasD: Bool = false) {
if hasD {
switch section {
case 0: self = .a
case 1: self = .b
@EricADockery
EricADockery / enum.swift
Last active February 10, 2018 15:45
Zebra Printer gist
enum CommonPrintingFormat: String {
case start = “! 0 200 200 150 1”
case end = “\nFORM\nPRINT “
}
enum CommonPrintingFormat: String {
case start = “! 0 200 200 150 1”
case end = “\nFORM\nPRINT “
}
private func didDisconnect(notification: Notification) {
isConnected = false
connectionDelegate?.connectionStatusChanged()
}
private func didConnect(notification: Notification) {
isConnected = true
connectionDelegate?.connectionStatusChanged()
}
protocol EAAccessoryManagerConnectionStatusDelegate {
func connectionStatusChanged() -> Void
}
var manager: EAAccessoryManager!
var isConnected: Bool = false
//new content from step1
var connectionDelegate: EAAccessoryManagerConnectionStatusDelegate?
// end new content
private var printerConnection: MfiBtPrinterConnection?
private var serialNumber: String?
private var disconnectNotificationObserver: NSObjectProtocol?
private var connectedNotificationObserver: NSObjectProtocol?
static let sharedInstance = PrintManager()
private override init() {
super.init()
manager = EAAccessoryManager.shared()
findConnectedPrinter { [weak self] bool in
if let strongSelf = self {
strongSelf.isConnected = bool
}
}
//Notifications
disconnectNotificationObserver = NotificationCenter.default.addObserver(forName: Notification.Name.EAAccessoryDidDisconnect, object: nil, queue: nil, using: didDisconnect)
deinit {
if let disconnectNotificationObserver = disconnectNotificationObserver {
NotificationCenter.default.removeObserver(disconnectNotificationObserver)
}
if let connectedNotificationObserver = connectedNotificationObserver {
NotificationCenter.default.removeObserver(connectedNotificationObserver)
}
}
func findConnectedPrinter(completion: (Bool) -> Void) {
let connectedDevices = manager.connectedAccessories
for device in connectedDevices {
if device.protocolStrings.contains(“com.zebra.rawport”) {
serialNumber = device.serialNumber
connectToPrinter(completion: { completed in
completion(completed)
})
}
}