Documentation:
- https://developer.apple.com/documentation/security/keychain_services
- https://developer.apple.com/documentation/security/errsecduplicateitem
Examples:
class_attributes.swift
lists attributes by classes
Documentation:
Examples:
class_attributes.swift
lists attributes by classesimport Foundation | |
@_exported import os.log | |
public extension OSLog { | |
convenience init(_ bundle: Bundle = .main, category: String? = nil) { | |
self.init(subsystem: bundle.bundleIdentifier ?? "default", category: category ?? "default") | |
} | |
convenience init(_ aClass: AnyClass, category: String? = nil) { |
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
import SwiftSyntax | |
@greeble(bork) typealias Element = Int | |
let typeAliasKeyword = SyntaxFactory.makeTypealiasKeyword(leadingTrivia: .spaces(1), | |
trailingTrivia: .spaces(1)) | |
let elementID = SyntaxFactory.makeIdentifier("Element", leadingTrivia: .zero, trailingTrivia: .spaces(1)) | |
let equal = SyntaxFactory.makeEqualToken(leadingTrivia: Trivia.zero, trailingTrivia: .spaces(1)) | |
let intType = SyntaxFactory.makeTypeIdentifier("Int", leadingTrivia: .zero, trailingTrivia: .zero) | |
let initializer = SyntaxFactory.makeTypeInitializerClause(equal: equal, value: intType) |
# Adapted from https://github.com/realm/realm-cocoa/blob/master/scripts/strip-frameworks.sh | |
# This script strips all non-valid architectures from dynamic libraries in | |
# the application's `Frameworks` directory which is required for App Store submission. | |
# | |
# The following environment variables are required: | |
# | |
# BUILT_PRODUCTS_DIR | |
# FRAMEWORKS_FOLDER_PATH | |
# VALID_ARCHS |
import Foundation | |
typealias ObserverRemover = () -> Void | |
/*! An observable value | |
An `Observable` wraps any value. If you add an observer handler, then every time the value is set, your handler will be | |
called with the new value. Adding an observer returns a closure that is used to remove the observer. Note that the handler | |
is called every time the value is set, even if this does not change the value. If you only want the handler to be called | |
when the value changes, see `CoalescingObservable`. |
#!/bin/bash | |
readonly lm75=0x48 # Slave address with A0, A1, and A2 set to 0v (ground). | |
while [ $# -gt 0 ] | |
do | |
if [ "$1" == "-debug" ] | |
then | |
debug=true | |
fi |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// UINavigationBar title | |
[[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]}]; | |
// UIBarButtonItem title | |
[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]} | |
forState:UIControlStateNormal]; | |
// UITabBarItem title | |
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1]} | |
forState:UIControlStateNormal]; |