Skip to content

Instantly share code, notes, and snippets.

View regularberry's full-sized avatar

Sean Berry regularberry

View GitHub Profile
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
class InjectedViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
print("INJECTED VIEW WILL APPEAR")
}
let alert = UIAlertController(title: "title", message: "message", preferredStyle: .alert)
alert.modalPresentationStyle = .fullScreen
print(alert.modalPresentationStyle.rawValue) // 4 aka ".custom"
UIModalPresentationStyle iPhone iPad
.fullScreen YES YES
.pageSheet YES NO
.formSheet YES NO
.currentContext YES YES
.custom NO NO
.overFullScreen NO NO
.overCurrentContext NO NO
.blurOverFullScreen  only on tvOS - N/A N/A
.popover YES NO
// Generated using Sourcery 0.15.0 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
import Foundation
protocol HasFancy {
func rockAndRoll()
func secondMethod() -> Int
}
class MockHasFancy: HasFancy {
func rockAndRoll() {
}
func secondMethod() -> Int {
}
}
{% macro methodSig method %}
func {{ method.name }}
{% if method.returnTypeName|!contains:"Void" %} -> {{method.returnTypeName}}{% endif %}
{% endmacro %}
{% for type in types.protocols %}
// sourcery:file:Mock{{ type.name }}.swift
import Foundation
class Mock{{ type.name }}: {{ type.name }} {
protocol UserStoreController {
func getAllUsers() -> [User]
func getUser(_ id: String) -> User
func openProfile(_ user: User)
}
struct SwiftStructForiOSThatContainsUserAgeData {
let age: Int
}
class ViewController: UIViewController, URLSessionTaskDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "http://0.0.0.0")!
let data = "Secret Message".data(using: .utf8)!
let tempDir = FileManager.default.temporaryDirectory
let localURL = tempDir.appendingPathComponent("throwaway")
try? data.write(to: localURL)
class ViewController: UIViewController, URLSessionTaskDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "http://0.0.0.0")!
let data = "Secret Message".data(using: .utf8)!
let request = URLRequest(url: url)
let config = URLSessionConfiguration.background(withIdentifier: "uniqueId")
let session = URLSession(configuration: config, delegate: self, delegateQueue: nil)
let task = session.uploadTask(with: request, from: data)