Migrates vocabulary words and word replacements from UserDefaults to SwiftData for better data management and persistence. Changes: - Create VocabularyWord and WordReplacement SwiftData models - Add dual ModelConfiguration setup (default.store for transcripts, dictionary.store for dictionary data) - Implement DictionaryMigrationService for one-time UserDefaults→SwiftData migration - Rename "Correct Spellings" to "Vocabulary" for clearer terminology - Update all dictionary views to use @Query instead of manager classes - Update all services to fetch from SwiftData using FetchDescriptor - Enhance word replacement duplicate detection (now checks during add AND edit) - Update import/export services to work with SwiftData - Preserve all existing functionality with improved data integrity Technical details: - Separate store files: default.store (transcripts) + dictionary.store (vocabulary + replacements) - Migration flag: "HasMigratedDictionaryToSwiftData_v2" - All CRUD operations properly implemented with duplicate detection
20 lines
499 B
Swift
20 lines
499 B
Swift
import Foundation
|
|
import SwiftData
|
|
|
|
@Model
|
|
final class WordReplacement {
|
|
var id: UUID
|
|
var originalText: String
|
|
var replacementText: String
|
|
var dateAdded: Date
|
|
var isEnabled: Bool
|
|
|
|
init(originalText: String, replacementText: String, dateAdded: Date = Date(), isEnabled: Bool = true) {
|
|
self.id = UUID()
|
|
self.originalText = originalText
|
|
self.replacementText = replacementText
|
|
self.dateAdded = dateAdded
|
|
self.isEnabled = isEnabled
|
|
}
|
|
}
|