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
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() | |
import UIKit | |
extension UIImageView { | |
func downloadImage(from url: URL) { | |
URLSession.shared.dataTask(with: url) { data, response, error in | |
guard | |
let httpURLResponse = response as? HTTPURLResponse, httpURLResponse.statusCode == 200, | |
let mimeType = response?.mimeType, mimeType.hasPrefix("image"), | |
let data = data, error == nil, |
// Based on https://code.tutsplus.com/articles/securing-communications-on-ios--cms-28529 | |
import Foundation | |
import Security | |
struct Certificate { | |
let certificate: SecCertificate | |
let data: Data | |
} | |
extension Certificate { |
import Foundation | |
struct MockDataConstants { | |
// MARK: - Image files | |
static let imageUrls: [String] = [ | |
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg", | |
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ElephantsDream.jpg", | |
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerBlazes.jpg", | |
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerEscapes.jpg", |