- Add BookmarkState enum with unread, favorite, and archived states - Extend API layer with query parameter filtering for bookmark states - Update Bookmark domain model to match complete API response schema - Implement BookmarkListView with card-based UI and preview images - Add BookmarkListViewModel with state management and error handling - Enhance BookmarkDetailView with meta information and WebView rendering - Create comprehensive DTO mapping for all bookmark fields - Add TabView with state-based bookmark filtering - Implement date formatting utilities for ISO8601 timestamps - Add progress indicators and pull-to-refresh functionality
33 lines
786 B
Swift
33 lines
786 B
Swift
import CoreData
|
|
import Foundation
|
|
|
|
class CoreDataManager {
|
|
static let shared = CoreDataManager()
|
|
|
|
private init() {}
|
|
|
|
lazy var persistentContainer: NSPersistentContainer = {
|
|
let container = NSPersistentContainer(name: "readeck")
|
|
container.loadPersistentStores { _, error in
|
|
if let error = error {
|
|
fatalError("Core Data error: \(error)")
|
|
}
|
|
}
|
|
return container
|
|
}()
|
|
|
|
var context: NSManagedObjectContext {
|
|
return persistentContainer.viewContext
|
|
}
|
|
|
|
func save() {
|
|
if context.hasChanges {
|
|
do {
|
|
try context.save()
|
|
} catch {
|
|
print("Failed to save Core Data context: \(error)")
|
|
}
|
|
}
|
|
}
|
|
}
|