-
UUID (Universally Unique Identifier): A sequence of 128 bits that can guarantee uniqueness across space and time, defined by [RFC 4122][rfc4122].
-
GUID (Globally Unique Identifier): Microsoft's implementation of the UUID specification; often used interchangeably with UUID.
-
UDID _(Unique Device Identifier)): A sequence of 40 hexadecimal characters that uniquely identify an iOS device (the device's Social Security Number, if you will). This value can be retrieved through iTunes, or found using UIDevice -uniqueIdentifier. Derived from hardware details like MAC address.
This file contains hidden or 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
// Copyright © 2019 Alexey Naumov. MIT License | |
import Combine | |
typealias CancelBag = Set<AnyCancellable> | |
extension CancelBag { | |
mutating func collect(@Builder _ cancellables: () -> [AnyCancellable]) { | |
formUnion(cancellables()) | |
} |
This file contains hidden or 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
func fetchContentLength(for url: URL, completionHandler: @escaping (_ contentLength: UInt64?) -> ()) { | |
var request = URLRequest(url: url) | |
request.httpMethod = "HEAD" | |
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in | |
guard error == nil, | |
let response = response as? HTTPURLResponse, | |
let contentLength = response.allHeaderFields["Content-Length"] as? String else { | |
completionHandler(nil) |
This file contains hidden or 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
func imageByAddingBorder(width: CGFloat, color: UIColor) -> UIImage? { | |
UIGraphicsBeginImageContext(self.size) | |
let imageRect = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height) | |
self.draw(in: imageRect) | |
let context = UIGraphicsGetCurrentContext() | |
let borderRect = imageRect.insetBy(dx: width / 2, dy: width / 2) | |
context?.setStrokeColor(color.cgColor) |
This file contains hidden or 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
let start = Date() | |
print("Elapsed time: \(start.timeIntervalSinceNow) seconds") |