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 notify | |
import Combine | |
enum Notify {} | |
extension Notify { | |
struct Status: Error { | |
let rawValue: UInt32 | |
init(_ rawValue: UInt32) { | |
self.rawValue = rawValue |
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
class FileMon { | |
static let queue = DispatchQueue(label: "FileMon") | |
let path: String | |
let file: Int32 | |
let source: DispatchSourceFileSystemObject | |
deinit { | |
source.cancel() | |
} |
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 CoreGraphics; | |
static const CGEventField kCGEventSubtype = 0x53; | |
static const CGEventField kCGEventData1 = 0x95; | |
static const CGEventField kCGEventData2 = 0x96; | |
static CGEventRef CGEventCreateMediaKeyEvent(CGEventSourceRef _Nullable source, int64_t key, BOOL down) { | |
CGEventFlags flags = (down ? NX_KEYDOWN : NX_KEYUP) << 8; | |
CGEventRef e = CGEventCreate(source); |
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 | |
guard let bundle = Bundle(identifier: "com.apple.CoreEmoji"), bundle.load() else { | |
fatalError() | |
} | |
let handle = dlopen(nil, RTLD_NOW) | |
typealias CEMCreateEmojiLocaleData_t = @convention(c) (CFLocaleIdentifier) -> CFTypeRef | |
let CEMCreateEmojiLocaleData = unsafeBitCast(dlsym(handle, "CEMCreateEmojiLocaleData"), |
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 <objc/runtime.h> | |
#import <objc/message.h> | |
template <typename RET, typename ...Types> | |
class ObjcMethodHook { | |
typedef RET(*_IMP)(id _self, SEL _cmd, Types...); | |
typedef RET(^_IMPBlock)(id _self, Types...); | |
private: | |
Class m_cls; |
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 <objc/runtime.h> | |
/** | |
To localize `UIBarButtonSystemItemDone` use "Done" key in your localizable.strings: | |
"Done" = "Localized_Done"; | |
*/ | |
__attribute__((constructor)) | |
static void Hack_NSBundle_localizedString () { |
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 UIKit; | |
@import ObjectiveC.runtime; | |
@interface MyDataSource: NSObject <UITableViewDataSource> | |
@end | |
@implementation MyDataSource | |
/** | |
Do not implement `numberOfSectionsInTableView:` to add it dynamically in runtime |
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 | |
let nc = NotificationCenter() | |
extension Notification.Name { | |
public static let ObservableDidChange = NSNotification.Name("ObservableDidChange") | |
} | |
let ObservableNewValueUserInfoKey = "new" | |
let ObservableOldValueUserInfoKey = "old" |