comparison GeoQuiz/Logic/PersistenceController.swift @ 23:02dcebb8cc4a

fix layout issues
author Dennis C. M. <dennis@denniscm.com>
date Thu, 27 Oct 2022 09:17:13 +0200
parents 56add5561261
children
comparison
equal deleted inserted replaced
22:56add5561261 23:02dcebb8cc4a
16 static var preview: PersistenceController = { 16 static var preview: PersistenceController = {
17 let result = PersistenceController(inMemory: true) 17 let result = PersistenceController(inMemory: true)
18 let viewContext = result.container.viewContext 18 let viewContext = result.container.viewContext
19 19
20 #if DEBUG 20 #if DEBUG
21 createMockData(nil, viewContext) 21 createMockData(with: viewContext)
22 #endif 22 #endif
23 23
24 return result 24 return result
25 }() 25 }()
26 26
39 39
40 container.viewContext.automaticallyMergesChangesFromParent = true 40 container.viewContext.automaticallyMergesChangesFromParent = true
41 } 41 }
42 42
43 #if DEBUG 43 #if DEBUG
44 static func createMockData(_ playedGames: FetchedResults<PlayedGame>?, _ moc: NSManagedObjectContext) { 44 static func createMockData(with moc: NSManagedObjectContext) {
45 for _ in 0..<10 { 45 for _ in 0..<10 {
46 let playedGame = PlayedGame(context: moc) 46 let playedGame = PlayedGame(context: moc)
47 47
48 playedGame.type = GameType(rawValue: Int16.random(in: 0...3))! 48 playedGame.type = GameType(rawValue: Int16.random(in: 0...3))!
49 playedGame.score = Int32.random(in: 0...50) 49 playedGame.score = Int32.random(in: 0...50)