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 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 | |
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 | |
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
let intArray = [1,2,3,4,5] | |
// using for loop | |
var forResult = [Int]() | |
for num in intArray { | |
forResult.append(num + 1) | |
} | |
print(forResult) // [2,3,4,5,6] |
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
let intArray = [[1,2],[3,4],[5]] | |
var flatMapResult = intArray.flatMap { $0 } | |
print(flatMapResult) // [1,2,3,4,5] |
OlderNewer