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 extension NSObject { | |
func removeNotifications() { | |
NSObject.cancelPreviousPerformRequests(withTarget: self) | |
NotificationCenter.default.removeObserver(self) | |
} | |
func addNotification(_ aSelector: Selector, key: String) { | |
NotificationCenter.default.addObserver(self, selector: aSelector, name: NSNotification.Name(rawValue: key), object: nil) | |
} |
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 struct Dispatch { | |
public static func main(block: @escaping ()->()) { | |
return DispatchQueue.main.async(execute: block) | |
} | |
public static func background(block: @escaping ()->()) { | |
return DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async(execute: block) | |
} |
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 struct Path { | |
public static var documents: String { return NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] } | |
public static var caches: String { return NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)[0] } | |
public static var library: String { return NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true)[0] } | |
public static var support: String { return NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true)[0] } | |
public static var temp: String { return NSTemporaryDirectory() } | |
public static var resource: String { return Bundle.main.resourcePath ?? "" } | |
@discardableResult public static func remove(_ path: String) -> Bool { | |
do { |
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 | |
import CommonCrypto | |
public typealias DigestHashFunc = @convention(c)(UnsafePointer<Void>, CC_LONG, UnsafeMutablePointer<UInt8>) -> UnsafeMutablePointer<UInt8> | |
public extension NSData { | |
var md4: NSData { return digetstHash(CC_MD4, CC_MD4_DIGEST_LENGTH) } | |
var md5: NSData { return digetstHash(CC_MD5, CC_MD5_DIGEST_LENGTH) } | |
var sha1: NSData { return digetstHash(CC_SHA1, CC_SHA1_DIGEST_LENGTH) } |
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
@interface NSFileHandle (fhreadline) | |
-(NSString*)readLine; | |
@end | |
@implementation NSFileHandle (fhreadline) | |
-(NSString*)readLine | |
{ | |
unsigned long long pos = [self offsetInFile]; | |
NewerOlder