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 | |
// 1. Import SwiftUI | |
import SwiftUI | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// 2. Initialize SwiftUI View |
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
// Created by Pedro Rojas (aka Pitt) | |
// Link to learn more about this code: https://youtu.be/kZ7JPFUVv1w | |
import SwiftUI | |
import WebKit | |
@resultBuilder | |
struct HtmlBuilder { | |
static func buildBlock() -> [HtmlTag] { | |
[] |
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 ContentView: View { | |
@State private var sliderValue: Double = 0.0 | |
@State private var backgroundColor: Color = .red | |
let colors: [Color] = [.red, .orange, .yellow, .green, .blue, .purple, .pink, .mint, .indigo, .teal, .cyan, .brown, .black] | |
var body: some View { | |
ZStack { |
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 | |
import SensitiveContentAnalysis | |
struct ContentView: View { | |
enum AnalysisState { | |
case notStarted | |
case analyzing | |
case isSensitive | |
case notSensitive |
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 Foundation | |
func benchmarkStringConversion() { | |
let dynamicString: String = "This is a string" | |
let iterations = 100_000 | |
var dynamicResult = 0 | |
let startDynamic = CFAbsoluteTimeGetCurrent() | |
for _ in 0..<iterations { | |
let utf8Data = Array(dynamicString.utf8) |
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 Foundation | |
struct CustomRandomNumberGenerator: RandomNumberGenerator { | |
private var state: UInt64 = 0 | |
private let multiplier: UInt64 = 6364136223846793005 | |
private let increment: UInt64 = 1442695040888963407 | |
private let modulus: UInt64 = UInt64.max // 2^64 - 1 | |
init(seed: UInt64) { | |
state = seed |
OlderNewer