Skip to content

Instantly share code, notes, and snippets.

View cgoldsby's full-sized avatar

Chris Goldsby cgoldsby

  • Zattoo, Inc.
  • Zürich, Switzerland
View GitHub Profile
@cgoldsby
cgoldsby / Suitest.podspec.json
Last active June 2, 2021 13:53
Suitest.podspec.json
{
"name": "Suitest",
"platforms": {
"tvos": "11.0",
"ios": "12.0"
},
"version": "1.5.0",
"summary": "Suitest is a test automation and device manipulation tool for AppleTV and iOS devices.",
"requires_arc": true,
"tvos": {
@cgoldsby
cgoldsby / psst.txt
Created March 28, 2019 11:24
psst! Down here!
┳┻|
┻┳|
┳┻| psst! Down here!
┻┳|
┳┻|
┻┳|
┳┻|
┻┳|
┳┻|
┻┳|
func myFunction() {
return _ = functionReturningString()
}
func functionReturningString() -> String {
return "Nothing to see here"
}
// Even works for a guard
func myFunction(value: Any?) {
func myFunction() {
return { print("All done") }() // Inline closure
}
func myFunction() {
return () // () -> Void
}
func myFunction() {
return Void() // Compiles!
func myFunction() {
defer { print("j/k... Now, I am done") }
return print("All done")
}
myFunction()
// Output:
// All done
// j/k... Now, I am done
func myFunction(value: Any?) {
guard let _ = value else { return valueIsNilDoSomething() }
valueIsNotNilDoSomethingElse()
}
func myFunction() {
return print("All done")
}
myFunction() // Output: All done
// MARK: - UIPopoverPresentationControllerDelegate
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
@cgoldsby
cgoldsby / popover-presentation-style.swift
Last active September 3, 2017 16:13
Display a popover with the same style as an iPad
final class ViewController: UIViewController, UIPopoverPresentationControllerDelegate {
...
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let popoverViewController = segue.destination
// Override the presentation style on the iPhone so that the popover does not appear in fullscreen
popoverViewController.popoverPresentationController?.delegate = self