Author: Chris Lattner
State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?
There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.
Here I present a composable pattern for pure state machiness with effects,
Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.
- [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
[UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached[UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead[UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.
javascript: | |
document.querySelectorAll('.load-diff-button').forEach(node => node.click()) |
This is largely based off of this article by Hulu and their roku-dev-cli tool.
Requirements:
The main requirement is a Mac with 2 available network interfaces WIFI <-> WIFI, LAN <-> WIFI, etc. This should work on other platforms as well but isn't covered here.
Setup
The first thing we need is Homebrew. If you've never used it before it's a great package manager for macOS that makes installing programs easier. Open Terminal and paste
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
and hit enter
import Dispatch | |
import Foundation | |
var x = 7 | |
let dd = withUnsafeBytes(of: &x, { DispatchData.init(bytes: $0) }) | |
print(dd as? Data) // Case 1: nil | |
print(dd as? NSData) // Case 2: nil | |
print(dd as Any as? Data) // Case 3: nil | |
print(dd as Any as? NSData) // Case 4: .some | |
print(dd as Any as? NSData as Data?) // Case 5: .some |
// | |
// GrowingTextView.swift | |
// https://gist.github.com/Bogidon/cc0c9ae6f041413c39fb0ff146ad1b18 | |
// | |
// Created by Bogdan Vitoc on 02/22/2017. | |
// Distributed under the MIT License: https://gist.github.com/Bogidon/cc0c9ae6f041413c39fb0ff146ad1b18#file-license | |
// | |
import UIKit |
Values of macros from TargetConditionals.h.
Xcode 7 / iOS 9.1, tvOS 9.0, watchOS 2.0, OS X 10.11 SDKs
Macro | 🖥 | 📱 | 📱sim | ⌚️ | ⌚️sim | 📺 | 📺sim |
---|---|---|---|---|---|---|---|
TARGET_OS_MAC |
1 | 1 | 1 | 1 | 1 | 1 | 1 |
TARGET_OS_IPHONE |
0 | 1 | 1 | 1 | 1 | 1 | 1 |
TARGET_OS_IOS |
0 | 1 | 1 | 0 | 0 | 0 | 0 |
TARGET_OS_WATCH |
0 | 0 | 0 | 1 | 1 | 0 | 0 |
{ | |
"aar": | |
{ | |
"int":["Afar"], | |
"native":["Afaraf"] | |
}, | |
"aa": | |
{ | |
"int":["Afar"], | |
"native":["Afaraf"] |