This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController, ViewControllerThatCanBlowUp { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
var viewControllersThatAreUnderSuspicionForBeingBlowUpable: [ViewControllerThatCanBlowUp] = [] | |
// Was seen buying a lot of fireworks | |
let vc1 = ViewController() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 🥤 | |
extension Dictionary where Key: RawRepresentable { | |
func rawConversion<NewKey>() -> Dictionary<NewKey, Value> where NewKey == Key.RawValue { | |
let newDict: [NewKey: Value] = self.reduce(into: [:]) { (result, item) in | |
result[item.key.rawValue] = item.value | |
} | |
return newDict | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Banana: NSObject, NSSecureCoding { | |
let bananaName: String | |
let userInfo: [String: Any] | |
static var supportsSecureCoding: Bool = true | |
init(bananaName: String, userInfo: [String: Any]) { | |
self.bananaName = bananaName | |
self.userInfo = userInfo | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Setting { | |
enum SettingIcon { | |
case system(name: String) | |
case custom(name: String) | |
} | |
enum SettingType: Equatable { | |
case toggle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Setting { | |
enum SettingIcon { | |
case system(name: String) | |
case custom(name: String) | |
} | |
enum SettingType: Equatable { | |
case toggle | |
case menu(settings: [MenuSetting]) | |
case viewController(creationBlock: (() -> UIViewController)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// TestSwiftSettings3 | |
// | |
// Created by Christian Selig on 2021-05-13. | |
// | |
import SwiftUI | |
import Combine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import AVKit | |
class ViewController: UIViewController { | |
override func viewDidAppear(_ animated: Bool) { | |
super.viewDidAppear(animated) | |
let videoURL = URL(string: "https://v.redd.it/dneaulg46lt61/HLSPlaylist.m3u8?a=1624119730%2CZjViMWYxNmQ3MjM2MWNhNjE1NTIyNGNiNDA5NDQ2Njk2ZjNhNmRmNmJiYmEwNzZkMTdmYjJkNmNkNzE2MTE0Yg%3D%3D&v=1&f=sd")! | |
let player = AVPlayer(url: videoURL) | |
let playerViewController = AVPlayerViewController() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
let url = URL(string: "https://external-preview.redd.it/nL7zG2Q2FkHwyJ15KgT4A7jk2R4cMddQpKb_Kx9YR8U.jpg?width=1080&crop=smart&auto=webp&s=91ee8327fdb33b3bb94cb0eab7e26221763e33f4")! | |
URLSession.shared.dataTask(with: url) { data, response, error in | |
print("Downloaded! Waiting…") | |
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(8)) { | |
// Immediately spikes approximately 7 MB upon execution |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIAlertController { | |
/// Creates a view controller for notifying the user that a conversion is occurring. Accepts a block that is executed upon conversion completion. | |
static func createConvertingAlertController(onConversionCompletion: @escaping () -> Void) -> UIAlertController { | |
// The title font corresponds to Dynamic Type style "Headline" | |
let titleFont = UIFont.preferredFont(forTextStyle: .headline) | |
let calculatorImageView = UIImageView(image: UIImage(named: "calculator.fill", in: nil, with: UIImage.SymbolConfiguration(font: UIFont.systemFont(ofSize: titleFont.pointSize * 2.0, weight: .semibold)))) | |
let measuringAttributedStringHeight = NSAttributedString(string: "Penguin", attributes: [.font: titleFont]).boundingRect(with: .zero, options: [.usesFontLeading, .usesLineFragmentOrigin], context: nil).height | |
let desiredOffset = 15.0 + calculatorImageView.bounds.height | |
let totalNewlinePrefixes = Int((desiredOffset / measuringAttributedStringHeight). |