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 | |
class Vehicle: Codable { | |
var seats: Int = 0 | |
init() { } | |
func move() { } | |
} |
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 UIKit | |
public extension UIView { | |
@discardableResult func align(_ type1: NSLayoutConstraint.Attribute, | |
with view: UIView? = nil, on type2: NSLayoutConstraint.Attribute? = nil, | |
offset constant: CGFloat = 0, | |
priority: Float? = nil) -> NSLayoutConstraint? { | |
guard let view = view ?? superview else { | |
return nil |
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 UniformTypeIdentifiers | |
import PhotosUI | |
@available(iOS 14, *) | |
extension PHPickerResult { | |
var fileName: String? { | |
guard let name = itemProvider.suggestedName else { return nil } | |
if let extn = itemProvider.itemType?.preferredFilenameExtension { | |
return name + ".\(extn)" |
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
class UserSettings: ObservableObject { | |
private init() { } | |
static let shared = UserSettings() | |
@Published var score = 0 | |
} |
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
class UserSettings: ObservableObject { | |
@Published var score = 0 | |
} | |
struct ContentView: View { | |
@EnvironmentObject var settings: UserSettings | |
var body: some View { | |
NavigationView { | |
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
import SwiftUI | |
/// An iOS style TabView that doesn't reset it's childrens navigation stacks when tabs are switched. | |
struct UIKitTabView: View { | |
var viewControllers: [UIHostingController<AnyView>] | |
@State var selectedIndex: Int = 0 | |
init(_ views: [Tab]) { | |
self.viewControllers = views.map { | |
let host = UIHostingController(rootView: $0.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
@objc class SuperClassA: NSObject { | |
public required override init() { } | |
public static var shared: SuperClassA { | |
if let instance = _shared { | |
return instance | |
} | |
return instance |
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 Introspect | |
public struct PasscodeField: View { | |
var maxDigits: Int = 4 | |
var label = "Enter One Time Password" | |
@State var pin: String = "" | |
@State var showPin = false |
NewerOlder