Sync monthly contributions y allocation targets vía iCloud (CoreData)
Ambos vivían en UserDefaults (device-local, no sincroniza). Migrados a atributos CoreData en entidades ya syncable=YES, así que ahora sincronizan por CloudKit: - InvestmentSource.monthlyContribution (Decimal, opcional) - Category.allocationTarget (Double, opcional) Los stores mantienen su API por UUID (0 cambios en call sites) pero ahora leen/escriben del atributo CoreData vía fetch por id. migrateIfNeeded(context:) mueve una sola vez los valores del diccionario UserDefaults legacy al modelo y borra la clave; enganchado en CoreDataStack.loadPersistentStores junto a MonthlyCheckInStore. DashboardLayoutStore se mantiene en UserDefaults a propósito (preferencia de UI por dispositivo: el columnSpan solo aplica en iPad). NOTA: requiere desplegar el schema CloudKit a producción (CD_monthlyContribution, CD_allocationTarget) antes de que sincronice en TestFlight/App Store. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015qUZrBusG82T37R7PeokqJ
This commit is contained in:
@@ -187,6 +187,9 @@ class CoreDataStack: ObservableObject {
|
||||
DispatchQueue.main.async {
|
||||
self?.isLoaded = true
|
||||
MonthlyCheckInStore.migrateIfNeeded()
|
||||
// Migrate device-local UserDefaults data into Core Data so it syncs via iCloud.
|
||||
MonthlyContributionStore.migrateIfNeeded(context: container.viewContext)
|
||||
AllocationTargetStore.migrateIfNeeded(context: container.viewContext)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user