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
/// iOS 15+ | |
func isPrewarm() -> Bool { | |
if let prewawrmEnv = ProcessInfo.processInfo.environment["ActivePrewarm"], | |
prewawrmEnv == "1" { | |
return true | |
} else { | |
return false | |
} | |
} |
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
protocol FooDelegate: AnyObject { | |
func didReceive(value: Int) | |
func didOpen() | |
func didClose() | |
} | |
class Foo { | |
weak var delegate: FooDelegate? | |
func open() { |
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 ComposableArchitecture | |
import SwiftUI | |
struct <#Name#>State: Equatable {} | |
enum <#Name#>Action: Equatable {} | |
struct <#Name#>Environment {} | |
extension <#Name#>Environment { |
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
protocol P { | |
associatedtype A | |
associatedtype B | |
} | |
protocol Q: P {} | |
extension Q where A == Int { | |
typealias B = Int | |
} |
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 Collapsable<Content: View>: View { | |
@State var collapsed: Bool = true | |
let content: () -> Content | |
init(@ViewBuilder content: @escapin () -> Content) { | |
self.content = content | |
} | |
var body: some View { | |
VStack { |
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 Foo { | |
var bar: Int | |
var overThreshold: Bool { | |
bar > 5 | |
} | |
} | |
let fooArray: [Foo] = ... | |
let filtered = fooArray.filter(\.overThreshold) |
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 | |
guard CommandLine.arguments.count > 1 else { | |
print("Please specify object file/executable") | |
exit(EXIT_FAILURE) | |
} | |
var nm = Process() | |
nm.launchPath = "/usr/bin/nm" | |
nm.arguments = [CommandLine.arguments[1]] |
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 Effect { | |
// Zip with other effects | |
func zip<Others: Collection>(with others: Others) | |
-> Effect<[Output], Failure> | |
where Others.Element == Effect<Output, Failure> { | |
let first = map { [$0] } | |
.eraseToEffect() | |
return others | |
.reduce(first) { zipped, next in |
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 Combine | |
import CombineExt // Check this implementation: https://github.com/CombineCommunity/CombineExt/blob/main/Sources/Operators/Create.swift | |
import CoreBluetooth | |
// Client to generate target delegate publisher | |
// Learned from https://github.com/pointfreeco/composable-core-location/blob/main/Sources/ComposableCoreLocation/Live.swift | |
struct PeripheralClient { | |
enum Action: Equatable { | |
case didUptateName |
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
// Kind of type | |
public enum Kind { | |
case `struct` | |
case `enum` | |
case optional | |
case opaque | |
case tuple | |
case function | |
case existential | |
case metatype |
NewerOlder