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 RealmSwift | |
import Realm | |
protocol CascadeDeleting { | |
func delete<S: Sequence>(_ objects: S, cascading: Bool) where S.Iterator.Element: Object | |
func delete<Entity: Object>(_ entity: Entity, cascading: Bool) | |
} | |
extension Realm: CascadeDeleting { | |
func delete<S: Sequence>(_ objects: S, cascading: Bool) where S.Iterator.Element: Object { |
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 CategoryViewController { | |
override func positionChanged(currentIndex: IndexPath, newIndex: IndexPath) { | |
// currentIndex and newIndex rows are swapped, implement accordingly | |
} | |
override func reorderFinished(initialIndex: IndexPath, finalIndex: IndexPath) { | |
// Gesture is finished and cell is back inside the table at finalIndex position | |
try! realm.write { | |
guard let sourceObject = categories?[initialIndex.row] else {fatalError()} |
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
// | |
// ThemeManager.swift | |
// ProjectThemeTest | |
// | |
// Copyright (c) 2017 Abhilash | |
// | |
import UIKit | |
import Foundation |
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
// | |
// ThemeManager.swift | |
import UIKit | |
import Foundation | |
/// Enum Theme Manager | |
/// - Note: https://github.com/durul/DRL-Theme-Manager | |
enum Theme: Int { | |
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
//Reading an Int | |
let number = Int(readLine()!)! | |
//Reading a Double | |
let decimalNumber = Double(readLine()!)! | |
//Reading a string | |
let text = readLine()! | |
//reading an array of Ints |
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
public class Network:NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLSessionDataDelegate { | |
internal static let sharedInstance = Network() | |
fileprivate var networkParams:Array<NetworkParams> = Array() | |
fileprivate func networkCall(_ request:URLRequest, completionBlock:@escaping NetworkCompletionBlock) | |
{ | |
let configurationId = String(format: "Network%d", arc4random()) | |
let configuration = URLSessionConfiguration.background(withIdentifier: configurationId) | |
configuration.timeoutIntervalForRequest = request.timeoutInterval |
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 | |
extension Data { | |
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription | |
guard let object = try? JSONSerialization.jsonObject(with: self, options: []), | |
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]), | |
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil } | |
return prettyPrintedString | |
} |
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 | |
public enum ColorSupport { | |
public static var label: UIColor { | |
if #available(iOS 13, *) { | |
return .label | |
} | |
return UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0) | |
} |
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 UIApplication { | |
class func appVersion() -> String { | |
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String | |
} | |
class func appBuild() -> String { | |
return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String | |
} |
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 network | |
import socket | |
import time | |
import struct | |
from machine import Pin | |
NTP_DELTA = 2208988800 | |
host = "pool.ntp.org" |