Skip to content

Instantly share code, notes, and snippets.

View rtking1993's full-sized avatar

Ryan King rtking1993

  • London
View GitHub Profile
@rtking1993
rtking1993 / CircleImage.swift
Last active June 5, 2019 16:29
CircleImage supporting view which is displayed within Safari Animals
// MARK: - Frameworks
import SwiftUI
// MARK: - CircleImage
struct CircleImage: View {
var image: Image
var body: some View {
@rtking1993
rtking1993 / AnimalRow.swift
Last active June 5, 2019 16:31
Animal Row for each animal in Safari Animals
// MARK: - Frameworks
import SwiftUI
// MARK: - AnimalRow
struct AnimalRow: View {
var animal: Animal
var body: some View {
@rtking1993
rtking1993 / AnimalDetail.swift
Last active June 5, 2019 16:31
Animal Details view for Safari Animals
// MARK: - Frameworks
import SwiftUI
// MARK: - AnimalDetail
struct AnimalDetail: View {
var animal: Animal
var body: some View {
@rtking1993
rtking1993 / AnimalList.swift
Last active June 5, 2019 16:31
Animal List for Safari Animals
// MARK: - Frameworks
import SwiftUI
// MARK: - AnimalList
struct AnimalList: View {
var body: some View {
NavigationView {
List(Animal.all) { animal in
@rtking1993
rtking1993 / Animals+Constants.swift
Created June 5, 2019 14:57
Constants file containing hardcoded animals for Safari Animals
// MARK: - Animal Constants
extension Animal {
static let all: [Animal] = [.lion, .elephant, .giraffe, .zebra]
static let lion = Animal(id: 1, name: "Lion",
description: "Biggest cat in Africa, the king of the jungle.",
imageName: "lion")
static let elephant = Animal(id: 2, name: "Elephant",
description: "Huge plant eating animal with long nose.",
@rtking1993
rtking1993 / Animal.swift
Created June 5, 2019 14:56
Animal model file for sample Safari Animals
// MARK: - Frameworks
import SwiftUI
// MARK: - Animal
struct Animal: Hashable, Identifiable {
// MARK: - Variables
@rtking1993
rtking1993 / JailbreakDetector.swift
Last active June 22, 2022 17:44
Jailbreak detector
extension UIDevice {
private class JailbreakDetector {
static var current: JailbreakDetector = JailbreakDetector()
lazy var containsSuspiciousFiles: Bool = {
return (["/Applications/Cydia.app",
"/Library/MobileSubstrate/MobileSubstrate.dylib",
"/bin/bash",
"/usr/sbin/sshd",
@rtking1993
rtking1993 / TorchFunction.swift
Last active February 12, 2019 11:19
Small function to use torch
func setTorch(on: Bool) {
guard let device = AVCaptureDevice.default(for: AVMediaType.video),
device.hasTorch else {
return
}
do {
try device.lockForConfiguration()
if on {
@rtking1993
rtking1993 / ClosureLoginExample.swift
Created February 8, 2019 11:48
Simple example of using closures
// MARK: LoginViewController
class LoginViewController: UIViewController {
func login(with username: String,
password: String) {
let authenticationSession = AuthenticationSession()
authenticationSession.performLogin(with: username,
password: password,
completion: { userIdentifier in
// MARK: LoginViewController
class LoginViewController: UIViewController, AuthenticationSessionDelegate {
func login(with username: String,
password: String) {
let authenticationSession = AuthenticationSession()
authenticationSession.delegate = self
authenticationSession.performLogin(with: username,
password: password)