Author: Chris Lattner
mr Marathi | |
bs Bosnian | |
ee_TG Ewe (Togo) | |
ms Malay | |
kam_KE Kamba (Kenya) | |
mt Maltese | |
ha Hausa | |
es_HN Spanish (Honduras) | |
ml_IN Malayalam (India) | |
ro_MD Romanian (Moldova) |
import UIKit | |
enum Direction { case In, Out } | |
protocol Dimmable { } | |
extension Dimmable where Self: UIViewController { | |
func dim(direction: Direction, color: UIColor = UIColor.blackColor(), alpha: CGFloat = 0.0, speed: Double = 0.0) { | |
@implementation CMFWallpaper | |
+ (void)setImage:(UIImage *)image { | |
NSAssert([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized, @"access to photos is needed to set the wallpaper"); | |
NSString *path; | |
#if TARGET_OS_SIMULATOR | |
path = @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibrary.framework"; | |
#else | |
path = @"/System/Library/PrivateFrameworks/PhotoLibrary.framework"; |
# The trick is to link the DeviceSupport folder from the beta to the stable version. | |
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :) | |
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5: | |
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport | |
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions | |
# (A similar approach works for older versions too, just change the version number after DeviceSupport) |
#import <AVFoundation/AVFoundation.h> | |
@interface MLWAsyncAVPlayer : AVPlayer | |
@end |
The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).
My take-aways are:
-
You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.
-
Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse
- (UIImage *)dynamicImage | |
{ | |
UITraitCollection *const baseTraitCollection = /* an existing trait collection */; | |
UITraitCollection *const lightTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]]]; | |
UITraitCollection *const purelyDarkTraitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]; | |
UITraitCollection *const darkTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, purelyDarkTraitCollection]]; | |
__block UIImage *lightImage; | |
[lightTraitCollection performAsCurrentTraitCollection:^{ | |
lightImage = /* draw image */; |
// | |
// AppDelegate.swift | |
// SwiftUITestApp | |
// | |
// Created by Matt Gallagher on 4/6/24. | |
// Copyright © 2019 Matt Gallagher. All rights reserved. | |
// | |
import Cocoa | |
import SwiftUI |
// | |
// UIView+Tooltips.h | |
// Crossword | |
// | |
// Created by Steven Troughton-Smith on 13/09/2019. | |
// Copyright © 2019 Steven Troughton-Smith. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> |