Defining a Publisher
pipeline, that Never
fails:
Before
let diamonds: AnyPublisher<Diamond, Never>
# install ffmpeg | |
brew install ffmpeg | |
# convert .mov file to .mp4 | |
ffmpeg -i demo.mov -vcodec h264 demo.mp4 |
import Combine | |
import UIKit | |
/// View controller, that publishes events for it's `view`'s lifecycle, | |
/// and allows type safe access to it's main `UIView`. | |
class ObservableViewController<V: UIView>: UIViewController { | |
typealias LifecycleEvent = (view: V, animated: Bool) | |
/// Broadcasts event after the controller's view is loaded, e.g. `viewDidLoad()`. |
import Foundation | |
import UIKit | |
import Combine | |
import PlaygroundSupport | |
/// The `ScopedReceivePublisher` modifies any returned `Publisher` property of `V` to receive | |
/// published elements on the specified `Scheduler`. | |
/// | |
/// Usage: | |
/// ``` |
You can constrain the content, the UIStackView
, to the contentLayoutGuide
top, bottom, leading, and trailing to define the scrollable area. You can then constrain the UIStackView
’s width to the frameLayoutGuide
so that it only scrolls vertically. That’s it—your content can now scroll as it shrinks or grows!
final class SomeView: UIView {
/// Quickly dump a UIImage from memory into a tmp file. | |
var image: UIImage? | |
// ... | |
let imageFilePath = NSTemporaryDirectory() + "\(Date().timeIntervalSince1970).png" | |
try? image.pngData()!.write(to: URL(fileURLWithPath: imageFilePath)) | |
print("Saved turn-by-turn advice image to: \(imageFilePath)") | |