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
| /// via: https://oleb.net/blog/2018/01/notificationcenter-removeobserver/ | |
| /// Wraps the observer token received from | |
| /// NotificationCenter.addObserver(forName:object:queue:using:) | |
| /// and unregisters it in deinit. | |
| final class NotificationToken: NSObject { | |
| let notificationCenter: NotificationCenter | |
| let token: Any | |
| init(notificationCenter: NotificationCenter = .default, token: Any) { | |
| self.notificationCenter = notificationCenter |
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
| extension SKProduct { | |
| func localizedPrice(divisor: Int) -> String { | |
| let formatter = NumberFormatter() | |
| formatter.numberStyle = .currency | |
| formatter.locale = self.priceLocale | |
| return formatter.string(from: | |
| self.price.dividing(by: NSDecimalNumber(value: divisor), | |
| withBehavior: NSDecimalNumberHandler(roundingMode: .down, | |
| scale: 2, |
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 Foundation | |
| extension NSData { | |
| func MD5() -> NSString { | |
| let digestLength = Int(CC_MD5_DIGEST_LENGTH) | |
| let md5Buffer = UnsafeMutablePointer<CUnsignedChar>.alloc(digestLength) | |
| CC_MD5(bytes, CC_LONG(length), md5Buffer) | |
| var output = NSMutableString(capacity: Int(CC_MD5_DIGEST_LENGTH * 2)) | |
| for i in 0..<digestLength { |
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
| // No Security | |
| { | |
| "rules": { | |
| ".read": true, | |
| ".write": true | |
| } | |
| } |
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
| // This is just a great implementation :D | |
| lazy var resumeTaskQueue: TaskQueue = { | |
| let _resumeTaskQueue = TaskQueue() | |
| _resumeTaskQueue.maxConcurrentTaskCount = 10 | |
| return _resumeTaskQueue | |
| }() |
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
| // MARK: - Manager | |
| class SaveManager { | |
| // MARK: Singleton | |
| private static let instance = SaveManager() | |
| class func sharedInstance () -> SaveManager { |
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
| func += <K, V> ( left: inout [K:V], right: [K:V]) { | |
| for (k, v) in right { | |
| left.updateValue(v, forKey: k) | |
| } | |
| } |