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
import UIKit | |
import Foundation | |
let queue = DispatchQueue(label: "wotjd", attributes: .concurrent) | |
func sendMessage(str: String, pendingTime: UInt32, completion: @escaping () -> Void) { | |
queue.async { | |
sleep(pendingTime) | |
print(str) | |
completion() |
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
// | |
// StackViewController.swift | |
// TableViewTest | |
// | |
// Created by edge on 06/11/2018. | |
// Copyright © 2018 castis. All rights reserved. | |
// | |
import UIKit |
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 String { | |
func isNewer(than compareVersion: String) -> Bool { | |
if self.compare(compareVersion, options: NSString.CompareOptions.numeric) == ComparisonResult.orderedDescending { | |
return true | |
} | |
return false | |
} | |
} |
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
import Foundation | |
/// RepeatingTimer mimics the API of DispatchSourceTimer but in a way that prevents | |
/// crashes that occur from calling resume multiple times on a timer that is | |
/// already resumed (noted by https://github.com/SiftScience/sift-ios/issues/52 | |
class RepeatingTimer { | |
// MARK: State | |
private enum State { | |
case suspended | |
case resumed |
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
import UserNotification | |
struct LocalNotification { | |
static func isDuplicatedNotification(identifier: String, completion: @escaping (Bool) -> () = {_ in}) { | |
UNUserNotificationCenter.current().getPendingNotificationRequests { notifications in | |
let dumNotis = notifications.filter { $0.identifier == identifier } | |
completion(!dumNotis.isEmpty) | |
} | |
} |
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
import Foundation | |
protocol Engine { | |
func startEngine() | |
func stopEngine() | |
} | |
class TrainEngine : Engine { | |
func startEngine() { | |
print("Engine started") |
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
import Foundation | |
public func FuntionScope(_ closure: () -> () ) { | |
closure() | |
} | |
public let TupleScope = { (c: () -> ()) in c() } | |
public let TupleExpScope: (() -> ()) -> () = { $0() } | |
// adding closure typealias |
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
import Foundation | |
let uuid = NSUUID().uuidString //"3B156152-8CD1-4845-A85C-1722AACC2453" | |
uuid.replacingOccurrences(of: "-", with: "") //"3B1561528CD14845A85C1722AACC2453" |
OlderNewer