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 myView = MyView(title: "Title", subTitle: "Sub title", content: "Content") | |
let myView2 = MyView(frame: .zero) | |
myView2.setTitle("Title", subTitle: "Sub title", content: "Content") |
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 SystemConfiguration | |
public class Reachability { | |
class func isConnectedToNetwork() -> Bool { | |
var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0)) | |
zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress)) | |
zeroAddress.sin_family = sa_family_t(AF_INET) | |
let defaultRouteReachability = withUnsafePointer(&zeroAddress) { | |
SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, UnsafePointer($0)) |
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
class TimeOut: NSObject { | |
private let queue:dispatch_queue_t | |
private let semaphore:dispatch_semaphore_t | |
var completion:()->() | |
convenience init(_ seconds:Double, completion:()->()) { | |
self.init(seconds, fireOn:dispatch_get_main_queue(), completion:completion) | |
} | |
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
// Swift 3 | |
func Delay(seconds: TimeInterval, _ completion: @escaping () -> Void) { | |
let when = DispatchTime.now() + seconds | |
DispatchQueue.main.asyncAfter(deadline: when) { | |
completion() | |
} | |
} |
NewerOlder