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
lazy var persistentContainer: NSPersistentContainer = { | |
let container = NSPersistentContainer(name: "app container name") | |
guard let fileContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "your group.app.identifier") else { | |
fatalError("Shared file container could not be created.") | |
} | |
let groupStoreUrl = fileContainer.appendingPathComponent("app container name.sqlite") | |
let hasOldStore = FileManager.default.fileExists(atPath: container.persistentStoreDescriptions.first?.url?.path ?? "") | |
let needsMigration = hasOldStore && container.persistentStoreDescriptions.first?.url?.absoluteString != groupStoreUrl.absoluteString |
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
extension CGMutablePath { | |
func addArrow(to point: CGPoint, tailWidth: CGFloat = 4.0, headWidth: CGFloat = 10.0, headLength: CGFloat = 14.0) { | |
let length = hypot(point.x - currentPoint.x, point.y - currentPoint.y) | |
let tailLength = length - headLength | |
let points: [CGPoint] = [ | |
CGPoint(x: 0.0, y: tailWidth / 2), | |
CGPoint(x: tailLength, y: tailWidth / 2), | |
CGPoint(x: tailLength, y: headWidth / 2), |