Skip to content

Instantly share code, notes, and snippets.

🤓
#working

Caleb Hess chess92

View GitHub Profile
@chess92
chess92 / network.swift
Last active May 17, 2017
Swift helper class for network connection (both wifi or cellular)
View network.swift
//
// Network 1.0
// Created by Caleb Hess on 2/22/16.
//
import SystemConfiguration
class Network {
func isConnected() -> Bool {
var zeroAddress = sockaddr_in()
@chess92
chess92 / string.swift
Last active May 17, 2017
Swift extension for string manipulation
View string.swift
//
// String 1.0
// Created by Caleb Hess on 8/16/16.
//
import Foundation
public extension String {
public var count: Int { return self.characters.count }
@chess92
chess92 / export.swift
Last active Feb 24, 2016
Swift class for opening a text message, phone, email, or web url.
View export.swift
//
// Export 1.0
// Created by Caleb Hess on 2/22/16.
//
#if os(iOS)
import UIKit
#else
import AppKit
#endif
@chess92
chess92 / ios.swift
Last active Feb 24, 2016
Swift Tips and Hacks pertaining only to iOS
View ios.swift
// -----------------------
// override silent mode
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
} catch {
print("could not override silent mode")
}
// -----------------------
@chess92
chess92 / osx.swift
Last active Feb 24, 2016
Swift Tips and Hacks pertaining only to OS X
View osx.swift
// -----------------------
// bring window to front
NSApp.activateIgnoringOtherApps(true)
// -----------------------
// close app when last window closes
func applicationShouldTerminateAfterLastWindowClosed(sender: NSApplication) -> Bool {
return true
}
You can’t perform that action at this time.