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
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 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 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 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 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 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 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 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 |
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 FixedViewController : UIViewController | |
@property(nonatomic) NSUInteger supportedInterfaceOrientations; | |
@end | |
@implementation FixedViewController | |
@end | |
... | |
- (void)rotateToInterfaceOrientation:(UIInterfaceOrientation)orientation |
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
+ (NSCharacterSet *)ignoredCharactersBeforeSmartInserts | |
{ | |
static NSCharacterSet *characterSet; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
/* | |
Character set taken from AppKit's __getPreSmartSet | |
*/ | |
NSMutableCharacterSet *mutableSet = [NSMutableCharacterSet characterSetWithCharactersInString:@"([\\\"'#$/-`{<"]; |