This guide shows how to create a dynamic API mock environment in Swift using Alamofire. You can intercept and respond to requests using a custom URLProtocol
, allowing you to return mock data instead of making real network calls — ideal for testing or development.
This guide shows how to create a dynamic API mock environment in Swift using Alamofire. You can intercept and respond to requests using a custom URLProtocol
, allowing you to return mock data instead of making real network calls — ideal for testing or development.
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 StickySegmentedScrollViewDynamicDemo: View { | |
var body: some View { | |
StickySegmentedScrollViewDynamic(tabs: [ | |
TabInfo(title: "Tab One", imageName: "video_cover_1") { | |
ForEach(0..<10) { i in | |
Text("Tab 1 - Item \(i)") | |
.frame(maxWidth: .infinity) | |
.padding() | |
.background(Color.red.opacity(0.1)) | |
.cornerRadius(8) |
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 | |
// MARK: - Tab Info | |
struct TabInfo<Content: View>: Identifiable { | |
let id = UUID() | |
let title: String | |
let imageName: String | |
let content: Content | |
} |
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 | |
import CryptoKit // Requires iOS 13.0 or later | |
/// Computes the MD5 checksum for a folder by hashing the contents of each file, including files in subdirectories. | |
/// | |
/// - Parameter folderURL: The URL of the folder. | |
/// - Returns: An MD5 checksum as a hexadecimal string, or `nil` if there was an error. | |
func generateMD5Checksum(for folderURL: URL) -> String? { | |
let fileManager = FileManager.default | |
var combinedHash = Data() |