Fix swift previews crash
This commit is contained in:
parent
06c2d156c9
commit
6cd7dae538
@ -10,13 +10,5 @@
|
|||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SuppressBuildableAutocreation</key>
|
|
||||||
<dict>
|
|
||||||
<key>7E943A1C273211C200E7DDF4</key>
|
|
||||||
<dict>
|
|
||||||
<key>primary</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import CoreData
|
||||||
|
|
||||||
struct K {
|
struct K {
|
||||||
static let posColors = [
|
static let posColors = [
|
||||||
@ -23,4 +24,11 @@ struct K {
|
|||||||
"oth": UIColor.systemBrown,
|
"oth": UIColor.systemBrown,
|
||||||
"extra": UIColor.systemBrown
|
"extra": UIColor.systemBrown
|
||||||
]
|
]
|
||||||
|
|
||||||
|
static var getFlashCardAnswersFetchRequest: NSFetchRequest<FlashCardAnswer> {
|
||||||
|
let request: NSFetchRequest<FlashCardAnswer> = FlashCardAnswer.fetchRequest()
|
||||||
|
request.sortDescriptors = []
|
||||||
|
|
||||||
|
return request
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,12 @@ import SwiftUI
|
|||||||
struct FlashCardResultsView: View {
|
struct FlashCardResultsView: View {
|
||||||
@Environment(\.managedObjectContext) private var viewContext
|
@Environment(\.managedObjectContext) private var viewContext
|
||||||
|
|
||||||
@FetchRequest(entity:FlashCardAnswer.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \FlashCardAnswer.word, ascending: false)], predicate: NSPredicate(format: "word == %@", "a")) var flashCardAnswers: FetchedResults<FlashCardAnswer>
|
@FetchRequest(fetchRequest: K.getFlashCardAnswersFetchRequest) var answers: FetchedResults<FlashCardAnswer>
|
||||||
|
|
||||||
@State private var statistics = 0.0
|
@State private var statistics = 0.0
|
||||||
|
|
||||||
func calculateStatistics() {
|
func calculateStatistics() {
|
||||||
print("count: \(flashCardAnswers.count)")
|
for answer in answers {
|
||||||
for answer in flashCardAnswers {
|
|
||||||
if answer.triesCount != 0 {
|
if answer.triesCount != 0 {
|
||||||
print("word: \(answer.word)")
|
print("word: \(answer.word)")
|
||||||
print("tries: \(answer.triesCount)")
|
print("tries: \(answer.triesCount)")
|
||||||
@ -25,16 +24,7 @@ struct FlashCardResultsView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// func calculateStatistics() {
|
|
||||||
// var correctAnswers = 0
|
|
||||||
// for answer in flashCardAnswers {
|
|
||||||
// if answer.correct {
|
|
||||||
// correctAnswers += 1
|
|
||||||
// }
|
|
||||||
// self.statistics = Double(correctAnswers) / Double(flashCardAnswers.count)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Text("Percentage: \(statistics)")
|
Text("Percentage: \(statistics)")
|
||||||
|
@ -39,7 +39,7 @@ extension Binding {
|
|||||||
struct FlashCardStack: View {
|
struct FlashCardStack: View {
|
||||||
@Environment(\.managedObjectContext) private var viewContext
|
@Environment(\.managedObjectContext) private var viewContext
|
||||||
|
|
||||||
@FetchRequest(entity:FlashCardAnswer.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \FlashCardAnswer.word, ascending: false)]) var flashCardAnswers: FetchedResults<FlashCardAnswer>
|
@FetchRequest(fetchRequest: K.getFlashCardAnswersFetchRequest) var flashCardAnswers: FetchedResults<FlashCardAnswer>
|
||||||
|
|
||||||
var dictionary: [TokiDictEntry]
|
var dictionary: [TokiDictEntry]
|
||||||
@State private var flashCards: [FlashCard] = []
|
@State private var flashCards: [FlashCard] = []
|
||||||
|
Loading…
Reference in New Issue
Block a user