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 Synchronization | |
| func untilCancelled() async { | |
| print("1") | |
| let mutex: Mutex<CheckedContinuation<Void, Never>?> = .init(nil) | |
| await withTaskCancellationHandler { | |
| print("2") | |
| await withCheckedContinuation { continuation in | |
| print("3") |
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
| /// A task that is cancelled if goes out of scope, i.e. the last reference on it has been discarded. | |
| public final class ScopedTask<Success: Sendable, Failure: Error>: Sendable { | |
| /// The underlying task | |
| let wrapped: Task<Success, Failure> | |
| /// Wraps a task into a scoped task. | |
| init(wrapping task: Task<Success, Failure>) { | |
| wrapped = task | |
| } | |
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 UnsafeMutablePointer<UInt8> { | |
| /// Returns the index of the first element in the buffer that is not `0` | |
| func firstIndexNotZero(size bufferSize: Int) -> Int? { | |
| let stride = MemoryLayout<SIMD16<UInt8>>.stride | |
| let simdSize = bufferSize / stride | |
| // Iterate buffer using 16-component SIMD vectors | |
| let simdIndex: Int? = withMemoryRebound(to: SIMD16<UInt8>.self, capacity: simdSize) { buffer in | |
| let zero = SIMD16<UInt8>(repeating: 0) | |
| return (0..<simdSize).first { buffer[$0] != zero } |
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 SwiftUI | |
| struct ContentView: View { | |
| @State var width: Float = 0 | |
| @State var weight: Float = 0 | |
| var body: some View { | |
| VStack { | |
| HStack{ | |
| Text("Width") |
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 SwiftUI | |
| public final class SwiftUIView<Content: View>: UIView { | |
| private let hostingController: UIHostingController<Content> | |
| public init(rootView: Content) { | |
| hostingController = UIHostingController(rootView: rootView) | |
| super.init(frame: .zero) |
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/Foundation.h> | |
| #import <AppKit/AppKit.h> | |
| int main(int argc, const char * argv[]) | |
| { | |
| @autoreleasepool { | |
| NSLog(@"languages: %@", [NSLocale.preferredLanguages componentsJoinedByString: @", "]); | |
| NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString: @"暗a"]; |
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
| // | |
| // UIViewController+Rotation.m | |
| // Ulysses | |
| // | |
| // Created by Götz Fabian on 12.10.17. | |
| // Copyright © 2017 Ulysses GmbH & Co. KG. All rights reserved. | |
| // | |
| #import "UIViewController+Rotation.h" |
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
| @implementation SwizzlingTextView /* Subclass of UITextView */ | |
| { | |
| BOOL _swizzled; | |
| } | |
| /* working solution */ | |
| - (void)setInputDelegate:(id<UITextInputDelegate>)inputDelegate | |
| { | |
| [super setInputDelegate: inputDelegate]; |
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
| // | |
| // MXSEventTrackingWindow.h | |
| // | |
| // Created by Max Seelemann on 01.09.16. | |
| // Copyright © 2016 The Soulmen. All rights reserved. | |
| // | |
| /*! | |
| @abstract Special window class used for advanced event processing. | |
| */ |
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
| COMPACT WIDTH (stacked view) | |
| - 320 x 568 pt | |
| -> iPhone 5, 5s | |
| - 320 x 768 pt | |
| -> iPad 9.7" Split Landscape 2/3 right | |
| - 320 x 834 pt | |
| -> iPad 10.5" Split Landscape 2/3 right | |
| - 320 x 1024 pt | |
| -> iPad 9.7" Split Portrait right |
NewerOlder