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
/* | |
By default, this class requires https://github.com/idrougge/sha1-swift to work, | |
you can replace the default SHA1 implementation by setting the hash property to a function | |
that takes a String and returns an optional String (the SHA1 hex string of the input) | |
*/ | |
/// Uses the pwnedpasswords API to verify password integrity | |
public final class PwnageVerifier { | |
/// The base URL for the pwnedpasswords service (a default is provided by the initializer) |
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
// This only has to be called once in the application's lifetime | |
NSKeyedUnarchiver.setClass(CALayer.self, forClassName: "KFVectorLayer") | |
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorFeatureLayer") | |
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorAnimationLayer") | |
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorGradientFeatureLayer") | |
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorBitmapFeatureLayer") | |
let path = Bundle.main.path(forResource: "YOUR_FILE_HERE", ofType: "caar")! | |
let archive = NSKeyedUnarchiver.unarchiveObject(withFile: path) as! [String: Any] | |
let animLayer = archive["rootLayer"] as! CALayer |
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
// This only has to be called once in the application's lifetime | |
[NSKeyedUnarchiver setClass:[CALayer class] forClassName:@"KFVectorLayer"]; | |
[NSKeyedUnarchiver setClass:[CAShapeLayer class] forClassName:@"KFVectorFeatureLayer"]; | |
[NSKeyedUnarchiver setClass:[CAShapeLayer class] forClassName:@"KFVectorAnimationLayer"]; | |
[NSKeyedUnarchiver setClass:[CAShapeLayer class] forClassName:@"KFVectorGradientFeatureLayer"]; | |
[NSKeyedUnarchiver setClass:[CAShapeLayer class] forClassName:@"KFVectorBitmapFeatureLayer"]; | |
NSString *path = [[NSBundle mainBundle] pathForResource:@"NAME_OF_YOUR_FILE" ofType:@"caar"]; | |
NSDictionary *archive = [NSKeyedUnarchiver unarchiveObjectWithData:[NSData dataWithContentsOfFile:path]]; | |
CALayer *animLayer = archive[@"rootLayer"]; |
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
public final class UserProfile: ModelObject { | |
@objc public dynamic var identifier: String = UUID().uuidString | |
@objc public dynamic var name: String = "" | |
@objc public dynamic var email: String = "" | |
public let referred = List<UserProfile>() | |
public let referrer = LinkingObjects(fromType: UserProfile.self, property: "referred") | |
} |
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
public class ModelObject: Object { | |
@objc public override func setValue(_ value: Any?, forKey key: String) { | |
// make sure we begin a write transaction if this is a managed object | |
self.realm?.beginWrite() | |
// actually do the update | |
super.setValue(value, forKey: key) | |
// commit the write transaction if managed |
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
record[.title] = title | |
record[.releaseDate] = date | |
record[.rating] = rating | |
// and so on... |
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
let record = CKRecord(recordType: "Movie") |
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
// | |
// PUPatternTextField.swift | |
// PeixeUrbano | |
// | |
// Created by Guilherme Rambo on 24/01/17. | |
// | |
// | |
import UIKit |
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
// | |
// MaskPattern.swift | |
// PeixeUrbano | |
// | |
// Created by Guilherme Rambo on 24/01/17. | |
// | |
// | |
import Foundation |
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
let containerIdentifier = "iCloud.br.com.guilhermerambo.KitchenContainer" | |
let secondContainer = CKContainer(identifier: containerIdentifier) |