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
- (void)captureOutput:(AVCapturePhotoOutput *)output didFinishProcessingPhoto:(AVCapturePhoto *)photo error:(NSError *)error { | |
assert(error == nil); | |
[PHPhotoLibrary.sharedPhotoLibrary performChanges:^{ | |
// ❌❌ | |
// UIImage *image = [[UIImage alloc] initWithCGImage:photo.CGImageRepresentation]; | |
// [PHAssetChangeRequest creationRequestForAssetFromImage:image]; | |
// [image release]; | |
// ❌❌ |
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 | |
final class FastEmunerator: NSFastEnumeration { | |
func countByEnumerating(with state: UnsafeMutablePointer<NSFastEnumerationState>, objects buffer: AutoreleasingUnsafeMutablePointer<AnyObject?>, count len: Int) -> Int { | |
state.pointee.itemsPtr = buffer | |
state.pointee.mutationsPtr = Unmanaged | |
.passUnretained(self) | |
.toOpaque() | |
.assumingMemoryBound(to: UInt.self) |
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> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
const unsigned char string[] = "ABC😇123😅abc🥹"; | |
unsigned char tmp[4] = {'\0', '\0', '\0', '\0'}; | |
for (size_t idx = 0; idx < (sizeof(string) / sizeof(unsigned char)); idx++) { | |
const unsigned char _char = string[idx]; |
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 Dispatch | |
class MySerialExecutor: SerialExecutor, @unchecked Sendable { | |
func enqueue(_ job: consuming ExecutorJob) { | |
let unownedJob = UnownedJob(job) | |
DispatchQueue(label: "FooQueue").async { | |
unownedJob.runSynchronously(on: .init(complexEquality: self)) | |
} | |
} |
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 | |
struct StringInterpolationParser: ExpressibleByStringInterpolation, CustomStringConvertible { | |
let result: String | |
var description: String { | |
result | |
} | |
init(stringLiteral value: String) { |
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 "Foo.h" | |
#import <UIKit/UIKit.h> | |
#import <objc/message.h> | |
#import <objc/runtime.h> | |
namespace ma_UIVisualStyleRegistry { | |
namespace visualStyleClassForStylableClass { | |
Class (*original)(id, SEL, Class); | |
Class custom(id self, SEL _cmd, Class stylableClass) { | |
if (stylableClass == UITabBarController.class) { |
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 AsyncStream { | |
@discardableResult | |
func yield(_ value: __owned Element) -> AsyncStream<Element>.Continuation.YieldResult { | |
let context = (Mirror(reflecting: self).descendant("context")! as AnyObject?)! | |
let storage = (Mirror(reflecting: context).descendant("storage")! as AnyObject?)! | |
let continuation = unsafeBitCast(storage, to: Self.Continuation.self) | |
_ = Unmanaged.passRetained(storage) | |
return continuation.yield(value) |
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 <objc/message.h> | |
#import <objc/runtime.h> | |
OBJC_EXPORT id objc_msgSendSuper2(void); | |
@interface TabBar : UITabBar | |
@end | |
@implementation TabBar | |
@end |
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 "ViewController.h" | |
@interface ViewController () | |
@property (retain, readonly, nonatomic) UIImageView *imageView; | |
@property (retain, readonly, nonatomic) UIVisualEffectView *blurView; | |
@property (retain, readonly, nonatomic) UIVisualEffectView *vibrancyView; | |
@property (retain, readonly, nonatomic) UIStackView *stackView; | |
@end | |
@implementation ViewController |
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 UIKit | |
import ObjectiveC | |
import CoreServices | |
// LSApplicationWorkspace * | |
fileprivate var applicationWorkspace: AnyObject { | |
let isa: AnyClass = objc_lookUpClass("LSApplicationWorkspace")! | |
let cmd = sel_registerName("defaultWorkspace") | |
let method = class_getClassMethod(isa, cmd) | |
let imp = method_getImplementation(method!) |
NewerOlder