Use _NS_4445425547 or NS🐞 for enables debuggging panel. When enabled it, a ladybug 🐞 menu appears in the app menu bar.
“4445425547” means DEBUG in Unicode table.
0x44=D
0x45=E
0x42=B
0x55=U
0x47=G
| import SwiftUI | |
| public extension View { | |
| /// Extension to sync local `@State` var with external `Binding`. | |
| /// | |
| /// Binding to `@Published` property of `ObservableObject` causes warning | |
| /// | |
| /// Publishing changes from within view updates is not allowed. | |
| func sync<T: Equatable>(_ external: Binding<T>, with local: Binding<T>) -> some View { | |
| onChange(of: external.wrappedValue) { _, newValue in |
| import Foundation | |
| extension UUID { | |
| // UUID is 128-bit, we need two 64-bit values to represent it | |
| var integers: (Int64, Int64) { | |
| var first: UInt64 = 0 | |
| first |= UInt64(uuid.0) | |
| first |= UInt64(uuid.1) << 8 | |
| first |= UInt64(uuid.2) << (8 * 2) | |
| first |= UInt64(uuid.3) << (8 * 3) |
| // https://azamsharp.com/2024/12/18/the-ultimate-guide-to-validation-patterns-in-swiftui.html | |
| import SwiftUI | |
| // Validation View Modifier | |
| struct ValidationModifier: ViewModifier { | |
| let errorMessage: String? | |
| func body(content: Content) -> some View { |
| extension View { | |
| /// Adds a double click handler this view (macOS only) | |
| /// | |
| /// Example | |
| /// ``` | |
| /// Text("Hello") | |
| /// .onDoubleClick { print("Double click detected") } | |
| /// ``` | |
| /// - Parameters: | |
| /// - handler: Block invoked when a double click is detected |
| func className(target: AnyObject) -> String { | |
| let nameSpaceClassName = NSStringFromClass(type(of: target)) | |
| if let className = nameSpaceClassName.components(separatedBy: ".").last { | |
| return className | |
| } | |
| return "" | |
| } |
| // TODO: - Change raw completion handlers once Swift issue is resolved. | |
| // https://github.com/apple/swift/issues/60488 | |
| public typealias DataTaskCompletion = (Data?, URLResponse?, Error?) -> Void | |
| public typealias DownloadTaskCompletion = (URL?, URLResponse?, Error?) -> Void | |
| /// async-await URLSessionTask wrapper with `cancel` and `suspend` functionality. | |
| public class AsyncURLSessionTask: Identifiable { | |
| enum State { | |
| case ready |
| import Foundation | |
| private let jsonDecoder: JSONDecoder = { | |
| let decoder = JSONDecoder() | |
| if #available(iOS 10.0, *) { | |
| decoder.dateDecodingStrategy = JSONDecoder.DateDecodingStrategy.iso8601 | |
| } | |
| return decoder | |
| }() |
| static const CGFloat kCornerRadiusStateNormal = 20.0f; | |
| static const CGFloat kCornerRadiusStateSelected = 40.0f; | |
| static const CGFloat kBorderWidth = 3.0f; | |
| // First variant, long and ugly | |
| - (void)updateStateAnimated:(BOOL)animated { | |
| if (animated) { | |
| CAMediaTimingFunction* timing =[[CAMediaTimingFunction alloc] initWithControlPoints:0.2f:0.0f:0.0f:1.0f]; |
| import UIKit | |
| final class SampleTableViewCell: UITableViewCell { | |
| static let cellHeight: CGFloat = 60.0 | |
| static let reuseIdentifier: String = String(describing: SampleTableViewCell.self) | |
| private let nameLabel: UILabel = UILabel() | |