A comprehensive study of how Apple and Swift.org official packages are structured, including file organization, naming conventions, code quality rules, formatting rules, and tooling patterns.
Packages Analyzed:
A comprehensive study of how Apple and Swift.org official packages are structured, including file organization, naming conventions, code quality rules, formatting rules, and tooling patterns.
Packages Analyzed:
| @propertyWrapper | |
| class Box<T> { | |
| var wrappedValue: T | |
| var projectedValue: Box<T> { | |
| Box(wrappedValue) | |
| } | |
| init(_ value: T) { | |
| self.wrappedValue = value |
| function run(input, parameters) { | |
| const appNames = []; | |
| const skipAppNames = []; | |
| const verbose = true; | |
| const scriptName = 'close_notifications_applescript'; | |
| const CLEAR_ALL_ACTION = 'Clear All'; | |
| const CLEAR_ALL_ACTION_TOP = 'Clear'; | |
| const CLOSE_ACTION = 'Close'; |
| import UIKit | |
| import MobileCoreServices.UTCoreTypes | |
| if #available(iOS 14.1, *) { | |
| let input = Bundle.main.url(forResource: "IMG_0037", withExtension: "HEIC")! | |
| let output = FileManager().temporaryDirectory.appendingPathComponent("IMG_0037.GAIN_MAP.BMP") | |
| let source = CGImageSourceCreateWithURL(input as CFURL, nil)! | |
| // urn:com:apple:photo:2020:aux:hdrgainmap | |
| let dataInfo = CGImageSourceCopyAuxiliaryDataInfoAtIndex(source, 0, kCGImageAuxiliaryDataTypeHDRGainMap)! as Dictionary |
| - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { | |
| NSString *tokenString; | |
| if (@available(iOS 13.0, *)) { | |
| NSUInteger dataLength = deviceToken.length; | |
| if (dataLength == 0) { | |
| return; | |
| } | |
| const unsigned char *dataBuffer = deviceToken.bytes; | |
| NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)]; |
JSC is the JavaScript engine from Apple's JavaScriptCore (WebKit) as a console application that you can use to run script in the terminal.
For more info visit the JSC's webkit wiki page.
Using jsc is simple, the one issue is that Apple keeps changing the location for jsc. To deal with this issue I just create a symbolic link to the binary:
| func debounce<T>(delay: TimeInterval, function: @escaping (T) -> Void, complete: @escaping () -> Void = { }) -> (T) -> Void { | |
| let queue = DispatchQueue(label: "Debouncer") | |
| var current: DispatchWorkItem? | |
| return { input in | |
| current?.cancel() | |
| let new = DispatchWorkItem { | |
| function(input) | |
| complete() | |
| } |
📝 企業を調べる時のメモ書きです。