This file contains 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 | |
@main | |
struct SettingsDemoApp: App { | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
} | |
Settings { |
This file contains 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 GeneralSettingsView: View { | |
@State private var settingOneValue = false | |
@State private var settingTwoValue = false | |
@State private var settingThreeValue = false | |
var body: some View { | |
Form { |
This file contains 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 String { | |
/** | |
Sanitizes the string by obscuring sensitive information. | |
- Returns: A sanitized version of the string where sensitive information is replaced with `*******`. | |
This method searches for specific keys (namely `access_token`, `refresh_token`, and `id_token`) in various formats including JSON-like strings, query strings, HTTP headers, plain text, and also searches for email addresses. It replaces their associated values or the email addresses with a placeholder string to obscure sensitive information. | |
## Examples: | |
This file contains 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 PlaygroundSupport | |
import Charts | |
// MARK: Chart implementation | |
struct ChartView: View { | |
@Binding var consumption: [Consumption] | |
var body: some View { |
This file contains 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 PlaygroundSupport | |
import Charts | |
// MARK: Chart implementation | |
struct ChartView: View { | |
@Binding var consumption: [Consumption] | |
var body: some View { |
This file contains 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
# Run tests with enableCodeCov YES, e.g. fastlane scan with code_coverage: true | |
# In your derived_data folder, run the following: | |
xcrun xcresulttool merge Logs/Test/*.xcresult --output-path bundle.xcresult # Combines all the XCResult files | |
xcrun xccov view --report --json bundle.xcresult > CodeCov-report.json # Generates the report into a JSON file |
This file contains 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 | |
let dictOne: [String: String] = [ | |
"key1": "value one", | |
"key2": "value two", | |
"key3": "value three", | |
"key4": "value four" | |
] | |
let dictTwo: [String: String] = [ |
This file contains 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 | |
// The definition of our struct | |
struct FooBar: Equatable{ | |
enum ItemType { | |
case main, sub | |
} | |
let itemType: ItemType | |
let name: String |
This file contains 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 | |
enum FooBar: String, CaseIterable { | |
case Foo | |
case Bar | |
} | |
enum BarFoo: CaseIterable { | |
case Bar | |
case Foo |
This file contains 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 FooBar { | |
let state: Bool | |
func isTrue() -> Bool { state } // Called 1000 times | |
func isFalse() -> Bool { !state } // Called 92 times | |
} | |
let fooList = (0..<1000).compactMap { n in FooBar(state: Bool.random()) } | |
let start = CFAbsoluteTimeGetCurrent() | |
if fooList.filter({ $0.isTrue() }).count > 1 { |
NewerOlder