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
class DroppingFramesHelper: NSObject { | |
private var firstTime: TimeInterval = 0.0 | |
private var lastTime: TimeInterval = 0.0 | |
func activate() { | |
let link = CADisplayLink(target: self, selector: #selector(update(link:))) | |
link.add(to: .main, forMode: .commonModes) | |
} |
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
extension UIImage { | |
class func decodedImage(_ image: UIImage) -> UIImage? { | |
guard let newImage = image.cgImage else { return nil } | |
// To optimize this, you can some cache control. | |
let colorspace = CGColorSpaceCreateDeviceRGB() | |
let context = CGContext(data: nil, | |
width: newImage.width, | |
height: newImage.height, | |
bitsPerComponent: 8, | |
bytesPerRow: newImage.width * 4, |
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
import UIKit | |
class AsyncImageView: UIView { | |
private var _image: UIImage? | |
var image: UIImage? { | |
get { | |
return _image | |
} |
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
extension UIImage { | |
class func circularImage(from image: UIImage, size: CGSize) -> UIImage? { | |
let scale = UIScreen.main.scale | |
let circleRect = CGRect(x: 0, y: 0, width: size.width * scale, height: size.height * scale) | |
UIGraphicsBeginImageContextWithOptions(circleRect.size, false, scale) | |
let circlePath = UIBezierPath(roundedRect: circleRect, cornerRadius: circleRect.size.width/2.0) | |
circlePath.addClip() |
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 testFirstNameNotEmpty() throws { | |
let forenames: [String] = customer.forenames | |
let firstName = try XCTUnwrap(forenames.first) | |
XCTAssertFalse(firstName.isEmpty) | |
} |
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
struct VpnChecker { | |
private static let vpnProtocolsKeysIdentifiers = [ | |
"tap", "tun", "ppp", "ipsec", "utun" | |
] | |
static func isVpnActive() -> Bool { | |
guard let cfDict = CFNetworkCopySystemProxySettings() else { return false } | |
let nsDict = cfDict.takeRetainedValue() as NSDictionary | |
guard let keys = nsDict["__SCOPED__"] as? NSDictionary, |