Skip to content

Instantly share code, notes, and snippets.

- (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];
// ❌❌
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)
#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];
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))
}
}
import Foundation
struct StringInterpolationParser: ExpressibleByStringInterpolation, CustomStringConvertible {
let result: String
var description: String {
result
}
init(stringLiteral value: String) {
#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) {
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)
#import <objc/message.h>
#import <objc/runtime.h>
OBJC_EXPORT id objc_msgSendSuper2(void);
@interface TabBar : UITabBar
@end
@implementation TabBar
@end
#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
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!)